Repository navigation
getTypeName: a class method descriptor isn't a named type (PyPy) - #593
Conversation
On PyPy, 'types.ClassMethodDescriptorType' is 'classmethod', and the built-in class method read from
'dict.__dict__["fromkeys"]' has no '__name__': getTypeName raised AttributeError, failing
'test_BuiltinMethodDescriptor' in all 8 PyPy jobs (dev run 39269675412).
- '_NAMED_TYPES' drops 'ClassMethodDescriptorType': such an unbound descriptor, read from a class' '__dict__', returns
the name of its class ('classmethod_descriptor' on CPython, 'classmethod' on PyPy). 'dict.fromkeys' reached
normally is a bound built-in method and keeps its name.
- Unwrapping 'classmethod'/'staticmethod' via '__func__' instead was measured and rejected: a class 57 -> 123 ns,
an instance 181 -> 216 ns (3.15).
- Tests: 'test_BuiltinClassMethod' ('dict.fromkeys'), 'test_ClassMethodDescriptor'. TypeName tests pass on 3.15,
3.13 and PyPy 3.11 (7.3.20).
Co-Authored-By: Patrick Lehmann <Paebbels@gmail.com>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
🟢 Coverage ∅ diff coverage · 0.00% coverage variation
Metric Results Coverage variation ✅ 0.00% coverage variation (-1.00%) Diff coverage ✅ ∅ diff coverage Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (3dfc28a) 15310 13855 90.50% Head commit (0fb94e5) 15309 (-1) 13854 (-1) 90.50% (0.00%) Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch:
<coverage of head commit> - <coverage of common ancestor commit>Diff coverage details
Coverable lines Covered lines Diff coverage Pull request (#593) 0 0 ∅ (not applicable) Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified:
<covered lines added or modified>/<coverable lines added or modified> * 100%
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #593 +/- ##
==========================================
- Coverage 87.85% 87.85% -0.01%
==========================================
Files 62 62
Lines 15310 15309 -1
Branches 2396 2396
==========================================
- Hits 13450 13449 -1
Misses 1455 1455
Partials 405 405
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Bug Fixes
pyTooling.Common.getTypeName(new in getTypeName: the name of an object's type without its module #592, not yet released) raisedAttributeError: 'classmethod' object has no attribute '__name__'on PyPy for a class method descriptor read from a class'__dict__(dict.__dict__["fromkeys"]). On PyPy,types.ClassMethodDescriptorTypeisclassmethod, and the built-in class methods carry no__name__. This failedTypeName::test_BuiltinMethodDescriptorin all 8 PyPy jobs;devis red since getTypeName: the name of an object's type without its module #592 (run 39269675412).ClassMethodDescriptorTypeis no longer one of the named types: such an unbound descriptor returns the name of its class,classmethod_descriptoron CPython andclassmethodon PyPy.dict.fromkeys, reached as usual, is a bound built-in method and keeps returningfromkeys.classmethod/staticmethodvia__func__inside the named branch keeps the name, but costs a class 57 → 123 ns and an instance 181 → 216 ns (Python 3.15).Unit Tests
tests/unit/Common/TypeName.py:test_BuiltinClassMethod(dict.fromkeys) andtest_ClassMethodDescriptor(the descriptor fromdict.__dict__returns its class' name). The TypeName tests pass on CPython 3.15, 3.13 and PyPy 3.11 (7.3.20, run locally).Related Issues and Pull-Requests