youknowone / wirerope

https://pypi.org/project/wirerope/
Other
6 stars 5 forks source link

Fix #14: support `super()` in wirerope #15

Closed huzecong closed 3 years ago

huzecong commented 3 years ago

This PR fixes issue #14: it adds support for calling super() for WireRope-decorated descriptors.

This is done by defining __set_name__ on the descriptor mixins. During class construction, for each descriptor defined in the class, its __set_name__ method (if exists) will be invoked with the class object and attribute name. This makes the descriptor aware of the class it's defined in, and the name it's associated with, which then allows us to differentiate between descriptors defined in a super class vs. those defined in the current class.

Due to implementation limits, this is only supported for Python 3.6+; other versions will use the old behavior.

For more information, see the Python docs or PEP 487.

codecov[bot] commented 3 years ago

Codecov Report

Merging #15 (606a5f3) into master (cffb262) will increase coverage by 0.72%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master      #15      +/-   ##
==========================================
+ Coverage   97.66%   98.38%   +0.72%     
==========================================
  Files           7        7              
  Lines         299      309      +10     
==========================================
+ Hits          292      304      +12     
+ Misses          7        5       -2     
youknowone commented 3 years ago

Thank you! released 0.4.5 with this change: https://pypi.org/project/wirerope/0.4.5/