-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
MyPy.ini Make Import Machinery Explicit #26645
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
@@ -57,7 +57,7 @@ def in_interactive_session(): | |||
|
|||
def check_main(): | |||
try: | |||
import __main__ as main | |||
import __main__ as main # type: ignore |
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 was ignored and won't be fixed as stated in mypy python/mypy#658, though perhaps a better solution would be to just use sys.stdin.isatty()
(follow up PR)
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.
IMO it would be nice to put a link the related mypy issue as comment too, for people in future who might be wonder why it's been ignored.
But l feel isattay()
is indeed the better solution.
Codecov Report
@@ Coverage Diff @@
## master #26645 +/- ##
==========================================
- Coverage 91.87% 91.87% -0.01%
==========================================
Files 174 174
Lines 50692 50692
==========================================
- Hits 46575 46572 -3
- Misses 4117 4120 +3
Continue to review full report at Codecov.
|
1 similar comment
Codecov Report
@@ Coverage Diff @@
## master #26645 +/- ##
==========================================
- Coverage 91.87% 91.87% -0.01%
==========================================
Files 174 174
Lines 50692 50692
==========================================
- Hits 46575 46572 -3
- Misses 4117 4120 +3
Continue to review full report at Codecov.
|
Side-note: will mypy look for config in setup.cfg? A lot of tools are moving to support that, and its nice to keep it all in one place. |
Yea we could migrate this to that file as well: |
Yeah keeping all configs at same place i.e. |
Whew a lot of external dependencies needs to be ignored and typeshed repo doesn't looks too active. Maybe I will add one of the our deps to typeshed. Let me know if you have one in mind(a small and simple one preferably). |
[mypy-pandas.io.msgpack._unpacker] | ||
ignore_missing_imports = True | ||
|
||
[mypy-pandas.io.sas._sas] |
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.
why do the cython libs have to be here?
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.
These throw errors like error: No library stub file for module ‘<the_pyx_file>’
- I imagine the annotations don't find anything that gets imported.
I think the only way around this may be to add stub files for the internally used aspects of the .pyx files but haven't found anything definitive yet. Also asked if anyone had experience with this on the typing Gitter but no luck yet. Stub files might not be a terrible fallback if that's all that works
why is this a good idea at this time? shouldn't we type more things first? |
I’m not totally against deferring but figured since mypy doesn’t suggest the previous method we had of totally ignoring missing imports I would rather make that explicit now so as to not silently introduce any new import errors with new annotations or changes
…Sent from my iPhone
On Jun 6, 2019, at 10:42 AM, Jeff Reback ***@***.***> wrote:
why is this a good idea at this time? shouldn't we type more things first?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Is this actually the recommended solution by mypy? it seems very strange since no libraries (that we need) actually have stubs. |
Calling it the recommended solution might be a little strong but our current method is the discouraged approach. Citing link from the OP:
So this PR would essentially move us from option 3 to option 2 above |
I am probably ok with option 2 for external libraries but what about our internal ones? (the _libs) these we should ‘fix’ |
Yea agreed on internal. Not saying we just keep these as is but we are ignoring them with the current mypy file. This PR makes it explicit and gives a checklist of items we can prioritize with the community to tackle |
Closing for now to keep queue clean. Can always revisit |
Now that we've wound down a lot of the mistyped annotations in the code base the next logical review point is our import machinery. Previously we used
ignore_missing_imports
for everything in the code base, but this is suggested by Mypy only as a last resort:https://mypy.readthedocs.io/en/latest/running_mypy.html#missing-imports
This PR makes the missing imports explicit. Third party libraries I think we'll have to keep until they become available in typeshed. Internal imports may be resolved through either stubfiles or internal import machinery (would need review as follow ups)