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

Spec for sys.meta_path too strict #2468

Closed
jaraco opened this issue Sep 19, 2018 · 10 comments · Fixed by #11890
Closed

Spec for sys.meta_path too strict #2468

jaraco opened this issue Sep 19, 2018 · 10 comments · Fixed by #11890
Labels
stubs: false positive Type checkers report false errors

Comments

@jaraco
Copy link
Member

jaraco commented Sep 19, 2018

In this comment, we learned that typeshed is too constrained on its spec for sys.meta_path, expecting instances of MetaPathFinder, whereas the existing values are of Type[MetaPathFinder], but more importantly, the objects there need not be instances of any particular class, but must conform to a protocol (having a .find_spec() or .find_module() on Python 3 and having a .find_module() on Python 2).

@pfmoore
Copy link
Member

pfmoore commented Nov 19, 2021

I've just hit this as well, here. Is there a workaround until it's fixed?

@layday
Copy link
Contributor

layday commented Nov 19, 2021

#6344

@Akuli
Copy link
Collaborator

Akuli commented Nov 19, 2021

I believe #5349 fixed this already, and mypy just uses an old version of typeshed.

@pfmoore
Copy link
Member

pfmoore commented Nov 19, 2021

I believe #5349 fixed this already

Nope, see my review comment on #6344. The current code doesn't allow for class or static methods.

@pfmoore
Copy link
Member

pfmoore commented Apr 9, 2022

Is there any progress on this? I'm reviewing whether to do anything to add type annotations to editables, and this is a blocker for me.

@layday
Copy link
Contributor

layday commented Apr 9, 2022

It looks like find_module and invalidate_caches were re-introduced in the typeshed at some point.

@layday
Copy link
Contributor

layday commented Apr 9, 2022

Actually, I was looking at the wrong place (at importlib.abc.MetaPathFinder), and that hasn't changed. Can you explain what problem is it that you are experiencing?

@pfmoore
Copy link
Member

pfmoore commented Apr 9, 2022

Sorry, I can't. My comment that I mentioned above seems to have been lost somehow.

I guess it'll have to wait until I get the motivation to try to apply types again, and I encounter the issue once more...

@abravalheri
Copy link
Contributor

@jaraco would #11890 be enough to address this issue? (it does not handle 2.7, or find_module as it is deprecated).

@jaraco
Copy link
Member Author

jaraco commented May 11, 2024

Yes, that sounds like a proper fix. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stubs: false positive Type checkers report false errors
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants