Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some python type hints for keypair #87

Merged
merged 5 commits into from
Jan 27, 2025
Merged

Conversation

camfairchild
Copy link
Contributor

@camfairchild camfairchild commented Jan 24, 2025

Addresses part of #86

@camfairchild camfairchild changed the title Feat/type hints Add some type hints Jan 24, 2025
@camfairchild camfairchild changed the title Add some type hints Add some python type hints for keypair Jan 24, 2025
bittensor_wallet/__init__.pyi Outdated Show resolved Hide resolved
bittensor_wallet/__init__.pyi Outdated Show resolved Hide resolved
@@ -0,0 +1,89 @@
from typing import Optional, Final
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
from typing import Optional, Final
from typing import Optional, Final, TYPE_CHECKING
if TYPE_CHECKING:
from scalecodec import ScaleBytes

Copy link
Contributor Author

@camfairchild camfairchild Jan 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will this work without scalecodec in the requirements?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will this work without scalecodec in the requirements?

kind of yes for the build. because TYPE_CHECKING will only work during the call of functions/methods where the annotation is checked.
SDK has scalecodec in the requirements. It gonna work via SDK.
But (theoretically) if someone wants to install the wallet package independently of SDK or BTCLI and tries to create an instance of the Keypair class, they will get an error when calling the sign and verify methods. I would add scalecodec to the wallet requirements with a version equal to the version in BTCLI and SDK

@camfairchild camfairchild merged commit 93d157d into staging Jan 27, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants