Skip to content

Conversation

@emmanuel-ferdman
Copy link

Changes

Fixes #539.

When checking if a class implements a protocol with a classmethod or staticmethod, typeguard only looked at the class's own __dict__ and missed inherited methods. This caused subclasses to fail protocol checks even when they properly inherit the required classmethod from a parent. The fix traverses the MRO to find where the method is actually defined.

Checklist

If this is a user-facing code change, like a bugfix or a new feature, please ensure that
you've fulfilled the following conditions (where applicable):

  • You've added tests (in tests/) added which would fail without your patch
  • You've updated the documentation (in docs/, in case of behavior changes or new
    features)
  • You've added a new changelog entry (in docs/versionhistory.rst).

Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
@coveralls
Copy link

Coverage Status

coverage: 94.718% (+0.01%) from 94.705%
when pulling 4a0c974 on emmanuel-ferdman:master
into 740c1d1 on agronholm:master.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

False positive in @classmethod check for subclasses

2 participants