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

TypeError in MerkleTree Properties in Python 3.8 Environment #53

Closed
olivmath opened this issue Dec 31, 2023 · 0 comments · Fixed by #54
Closed

TypeError in MerkleTree Properties in Python 3.8 Environment #53

olivmath opened this issue Dec 31, 2023 · 0 comments · Fixed by #54
Assignees
Labels
bug Something isn't working

Comments

@olivmath
Copy link
Owner

Environment

  • Python Version: 3.8
  • Library Version: [Versão da biblioteca, se aplicável]

Description of the Issue

When running tests using Python 3.8, a TypeError is encountered in the MerkleTree class, specifically in the human_leaves and human_short_leaves properties. This issue does not occur in Python 3.9 or 3.10, indicating it's likely related to type hinting compatibility with Python 3.8.

Error Message

TypeError: 'type' object is not subscriptable

This error occurs when collecting tests that import and use the MerkleTree class.

Steps to Reproduce

  1. Set up a Python 3.8 environment.
  2. Run pytest on the codebase.
  3. Observe the TypeError in the collection phase of the pytest.

Expected Behavior

The MerkleTree class should function correctly without type errors across different Python versions, especially in supported versions like Python 3.8.

Actual Behavior

A TypeError is raised due to the use of Python 3.9+ style list type hints (e.g., list[str]) which are not compatible with Python 3.8.

Possible Solution

Replace the Python 3.9+ list type hints with the Python 3.8 compatible format using the typing module. For instance, change:

@property
def human_leaves(self) -> list[str]:
    ...

to

from typing import List

@property
def human_leaves(self) -> List[str]:
    ...

and similarly for human_short_leaves.

@olivmath olivmath added the bug Something isn't working label Dec 31, 2023
@olivmath olivmath self-assigned this Dec 31, 2023
@olivmath olivmath linked a pull request Dec 31, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant