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

Based type parser #1

Open
KotlinIsland opened this issue Dec 21, 2021 · 2 comments · May be fixed by #90
Open

Based type parser #1

KotlinIsland opened this issue Dec 21, 2021 · 2 comments · May be fixed by #90
Labels

Comments

@KotlinIsland
Copy link
Owner

KotlinIsland commented Dec 21, 2021

class A:
    a: 1 | 2
based typing.get_annotations(A) # {"a": Union[1, 2]
# such that `1 | 2` == `Union[1, 2]`, not `3`
#  and `A & B` is `basedtyping.Intersection`

No idea how this will work with the new type alias syntax in 3.12, maybe we can raise that they should have a .value or something.

@DetachHead DetachHead transferred this issue from KotlinIsland/basedtyping-ded Dec 21, 2021
@DetachHead
Copy link
Collaborator

is this something we can even do in basedtyping? is it more like a basedmypy issue

@KotlinIsland
Copy link
Owner Author

This is definitely a basedtyping issue, look at the impl of typing.ForwardRef._evaluate, it uses eval to just execute the type which will cause runtime errors. We need to make a impl that treats it as types, not normal python exprs.

@KotlinIsland KotlinIsland changed the title parse types properly, not as expressions Based type parser Dec 9, 2023
@KotlinIsland KotlinIsland linked a pull request Dec 13, 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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants