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

fix typing for python 3.8 #42

Merged
merged 2 commits into from
May 6, 2024
Merged

fix typing for python 3.8 #42

merged 2 commits into from
May 6, 2024

Conversation

sutt
Copy link
Contributor

@sutt sutt commented May 5, 2024

Observed behavior: Install from pypi (pip install bolt11) succeeds, but bolt11 decode fails with TypeError: 'type' object is not subscriptable in utils.py on line:

def verify_hrp(hrp: str) -> tuple[str, Optional[MilliSatoshi]]:

This occurs because subscripting the built-in tuple type with type hints is only supported in Python 3.9 and later. The type hint should be changed to Tuple from the typing module, which is supported in Python 3.8 and later.

Since the pypi package lists support as >=3.8.1, this PR adds a simple way to bring support to 3.8. After applying the fix blot11 decode works.

On 3.8 - it fails

Python 3.8.10 (default, Nov 14 2022, 12:59:47) 
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.version
'3.8.10 (default, Nov 14 2022, 12:59:47) \n[GCC 9.4.0]'
>>> tuple[str, int]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'type' object is not subscriptable

On 3.9 - it succeeds

Python 3.9.7 (default, Sep 16 2021, 13:09:58) 
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.version
'3.9.7 (default, Sep 16 2021, 13:09:58) \n[GCC 7.5.0]'
>>> tuple[str, int]
tuple[str, int]

@dni
Copy link
Member

dni commented May 5, 2024

support for python 3.8 will be dropped in the future, fine for now! thanks!

Copy link
Member

@dni dni left a comment

Choose a reason for hiding this comment

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

ci failing formatting

@dni dni self-requested a review May 6, 2024 08:12
@dni dni merged commit 12e0205 into lnbits:main May 6, 2024
5 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