-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
CLN, TYP Remove string type hints #39299
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
CLN, TYP Remove string type hints #39299
Conversation
d9d143c
to
0af31a3
Compare
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.
wow. lgtm. cc @simonjayhawkins
just have to make sure the author sticks around :->
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 is great! Just one question below.
if TYPE_CHECKING: | ||
from numpy.ma.mrecords import MaskedRecords | ||
|
||
from pandas import Series |
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.
Curious what happened here. Series is imported inline below, so am I correct to say that this is sufficient for 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.
Thanks!
And yes, seems like it, e.g.:
t.py
:
def foo() -> None:
a: List[int]
reveal_type(a)
from typing import List
$ python3.8 -m mypy t.py
t.py:3: note: Revealed type is 'builtins.list[builtins.int]'
Thanks @MarcoGorelli. this is great. |
Thanks all for your kind words, much appreciated 🙏 ! |
For some background: there was some consensus on doing this here
Then here there was the suggestion to use
ast.parse
, rather than regular expressions. I had a go at that, and made this into its own package: https://github.com/MarcoGorelli/no-string-hints , which I've included here as a pre-commit hookThe changes here are just a result of running
pre-commit run no-string-hints -a
, and then addingfrom __future__ import annotations
to some files.