Skip to content

Spec for sys.meta_path too strict #2468

Closed

Description

@jaraco

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).

Activity

  1. pfmoore commented on Nov 19, 2021

    @pfmoore
    Member

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

  2. layday commented on Nov 19, 2021

    @layday
    Contributor
  3. Akuli commented on Nov 19, 2021

    @Akuli
    Collaborator

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

  4. pfmoore commented on Nov 19, 2021

    @pfmoore
    Member

    I believe #5349 fixed this already

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

  5. pfmoore commented on Apr 9, 2022

    @pfmoore
    Member

    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.

  6. layday commented on Apr 9, 2022

    @layday
    Contributor

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

  7. layday commented on Apr 9, 2022

    @layday
    Contributor

    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?

  8. pfmoore commented on Apr 9, 2022

    @pfmoore
    Member

    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...

  9. abravalheri commented on May 11, 2024

    @abravalheri
    Contributor

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

  10. jaraco commented on May 11, 2024

    @jaraco
    MemberAuthor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions