Skip to content

Fix typechecking on Python 3.8 #7953

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

Merged
merged 1 commit into from
Nov 14, 2019
Merged

Fix typechecking on Python 3.8 #7953

merged 1 commit into from
Nov 14, 2019

Conversation

msullivan
Copy link
Collaborator

The Python 3.8 ast stubs now (correctly!) indicate that a key in Dict
can be None. Fix fastparse to deal with this. Really the typed_ast stubs
should say this also.

The Python 3.8 ast stubs now (correctly!) indicate that a key in Dict
can be None. Fix fastparse to deal with this. Really the typed_ast stubs
should say this also.
Copy link
Member

@ilevkivskyi ilevkivskyi left a comment

Choose a reason for hiding this comment

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

Thanks! I just have one suggestion.

for e in l:
exp = self.visit(e)
res.append(exp)
return res

def translate_expr_list(self, l: Sequence[AST]) -> List[Expression]:
Copy link
Member

Choose a reason for hiding this comment

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

Maybe you can use an overload instead?

@overload
def translate_expr_list(l: Sequence[AST]) -> List[Expression]: ...
@overload
def translate_expr_list(l: Sequence[Optional[AST]]) -> List[Optional[Expression]]: ...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I tried that first and it complained that they overlapped

Copy link
Member

Choose a reason for hiding this comment

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

Hm, I think I remember having similar troubles with get_proper_types(). @Michael0x2a is this actually unsafe or maybe we can relax this somehow (I mean invariant generics in return types)?

@msullivan msullivan merged commit 3b5a62e into master Nov 14, 2019
@msullivan msullivan deleted the fix-38 branch November 14, 2019 21:11
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