-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Eliminate some conditional method defs in fastparse #5499
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
Conversation
It seems like they might not be necessary anymore, and mypyc doesn't support it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but there is a problem.
mypy/fastparse.py
Outdated
@overload | ||
def visit(self, node: ast3.expr) -> Type: ... | ||
@overload | ||
def visit(self, node: ast3.expr) -> Type: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will fail on 3.5.1
mypy/fastparse.py
Outdated
def visit(self, node: Optional[ast3.AST]) -> Any: | ||
return self._visit_implementation(node) | ||
def visit(self, node: Optional[ast3.AST]) -> Optional[Type]: # noqa | ||
return self._visit_implementation(node) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I think _visit_implementation
only existed because of conditional definition, you can kill it now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
mypy/fastparse.py
Outdated
@@ -67,6 +67,13 @@ | |||
TYPE_COMMENT_AST_ERROR = 'invalid type comment or annotation' | |||
|
|||
|
|||
# Older versions of typing don't allow using overload outside stubs, | |||
# so provide a dummy. | |||
if sys.version_info < (3, 6): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be guarded with a big if not MYPY:
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mypy didn't seem to care, but probably ought to anyways
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On 3.4, the version of typing is newer than on 3.5, so you lose some type safety on 3.4. It works because you are only making the signature less exact, but it is more correct to use if MYPY
.
It seems like they might not be necessary anymore, and mypyc doesn't
support it.