Skip to content

getTypeName: a class method descriptor isn't a named type (PyPy) - #593

Merged
Paebbels merged 1 commit into
devfrom
claude/type-name-pypy
Oct 19, 2026
Merged

Paebbels merged 1 commit into
devfrom
claude/type-name-pypy

Conversation

@pytooling-claude

Copy link
Copy Markdown

Bug Fixes

  • pyTooling.Common.getTypeName (new in getTypeName: the name of an object's type without its module #592, not yet released) raised AttributeError: 'classmethod' object has no attribute '__name__' on PyPy for a class method descriptor read from a class' __dict__ (dict.__dict__["fromkeys"]). On PyPy, types.ClassMethodDescriptorType is classmethod, and the built-in class methods carry no __name__. This failed TypeName::test_BuiltinMethodDescriptor in all 8 PyPy jobs; dev is red since getTypeName: the name of an object's type without its module #592 (run 39269675412).
  • ClassMethodDescriptorType is no longer one of the named types: such an unbound descriptor returns the name of its class, classmethod_descriptor on CPython and classmethod on PyPy. dict.fromkeys, reached as usual, is a bound built-in method and keeps returning fromkeys.
  • Rejected alternative: unwrapping classmethod/staticmethod via __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) and test_ClassMethodDescriptor (the descriptor from dict.__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

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>
@pytooling-claude
pytooling-claude Bot requested a review from Paebbels as a code owner October 19, 2026 17:46
@pytooling-claude pytooling-claude Bot added bug Something isn't working Platform pyTooling.Common.Platform - Detecting current platform. Unit Tests labels Oct 19, 2026
@codacy-production

codacy-production Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

🟢 Coverage ∅ diff coverage · 0.00% coverage variation

Metric Results
Coverage variation ✅ 0.00% coverage variation (-1.00%)
Diff coverage ✅ ∅ diff coverage

View coverage diff in Codacy

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

codecov Bot commented Oct 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.85%. Comparing base (3dfc28a) to head (0fb94e5).
✅ All tests successful. No failed tests found.

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              
Flag Coverage Δ
unittests 87.85% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Paebbels
Paebbels merged commit 284d2f9 into dev Oct 19, 2026
65 checks passed
@Paebbels
Paebbels deleted the claude/type-name-pypy branch October 19, 2026 18:32
@pytooling-claude pytooling-claude Bot added this to the v10.0 milestone Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Platform pyTooling.Common.Platform - Detecting current platform. Unit Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants