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

Refactor and simplify HasTraits method checks #1176

Merged
merged 1 commit into from
Jul 13, 2020

Conversation

mdickinson
Copy link
Member

The HasTraits machinery needs function and method checks at various points, mostly to look for magic-named methods like _mytrait_changed and _myevent_fired.

Those checks are currently performed inconsistently, and for methods written in Cython also rely on a rather fragile mechanism for recognising the method. (That mechanism also fails for C extensions other than Cython extensions.)

This PR:

  • makes the checks consistent: they all now rely on the _is_unbound_method_type helper function.
  • uses inspect.ismethoddescriptor as a better way to catch something that behaves like an unbound method without relying on Cython-specific details
  • cleans up unused related functions and constants

Copy link
Contributor

@kitchoi kitchoi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mdickinson mdickinson merged commit 2c43aec into master Jul 13, 2020
@mdickinson mdickinson deleted the refactor/function-and-method-type-checks branch July 13, 2020 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants