FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Protocols don't support descriptors · Issue #5481 · python/mypy · GitHub

Repository navigation

Protocols don't support descriptors #5481

Closed

Description

Consider this code:

class Descr:
    def __get__(self, inst: Any, owner: Any) -> int: ...

class Proto(Protocol):
    x: int

class C:
    x = Descr()

a: Proto = C()

I think it should be allowed. This can be done by simply re-using the logic in analyze_member_access in checkmember.py, see also #5136.

Activity

  1. bryanforbes commented on Jan 30, 2019

    Contributor

    This will be fixed when #3832 is complete

  2. ilevkivskyi commented on Dec 19, 2019

    MemberAuthor

    This appeared again in dropbox/sqlalchemy-stubs#134

  3. ckarnell commented on Dec 20, 2019

    Contributor

    Can you tell me exactly where in the code the duplication is happening WRT Protocols, so I can try to piece together some understanding and look into fixing it? I'm looking myself but it's not immediately obvious, and I'm unfamiliar with the codebase.

  4. ilevkivskyi commented on Dec 20, 2019

    MemberAuthor

    Just to set realistic expectations: it is unlikely anyone beyond core team can fix this. But anyway, the problematic logic duplication is between is_protocol_implementation()/find_member() in subtypes.py and analyze_instance_member_access() in checkmember.py.

  5. ckarnell commented on Dec 21, 2019

    Contributor

    Got it, makes sense. I might take a peek anyway just out of curiosity.

  6. sobolevn commented on Jun 23, 2021

    Member

    This was raised once again in django-stubs repo: typeddjango/django-stubs#651

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL