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

Crossandra v2.1.0 and v2.2.0 fail on mypyc wheels #36

Closed
trag1c opened this issue May 29, 2024 · 0 comments · Fixed by #37
Closed

Crossandra v2.1.0 and v2.2.0 fail on mypyc wheels #36

trag1c opened this issue May 29, 2024 · 0 comments · Fixed by #37
Labels
bug Something isn't working

Comments

@trag1c
Copy link
Owner

trag1c commented May 29, 2024

MRE:

from enum import Enum

from crossandra import Crossandra


class Token(Enum):
    FOO = "x"


Crossandra(Token)
Traceback (most recent call last):
  File "/Users/trag1c/dev/playground/temp-b9b2ed1/main.py", line 10, in <module>
    Crossandra(Token)
  File "crossandra/lib.py", line 103, in __init__
  File "crossandra/lib.py", line 40, in generate_tree
TypeError: dict object expected; got None

File "crossandra/lib.py", line 40, in generate_tree

def generate_tree(inp: Iterable[tuple[str, Enum]]) -> Tree:
inp = sorted(inp, key=lambda v: len(v[0]), reverse=True)
result: Tree = {}
for k, v in inp:
curr = result
for c in k[:-1]:
curr = cast(Tree, curr.setdefault(c, {}))
if dct := cast(Tree, curr.get(k[-1])):
dct[""] = v
else:
curr[k[-1]] = v
return result

Seems like mypyc doesn't like casts?

@trag1c trag1c added the bug Something isn't working label May 29, 2024
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