Skip to content

Zero-arg class-body functions stay values - #32

Merged
dpep merged 1 commit into
mainfrom
zero-arg-class-attrs
Oct 27, 2026
Merged

dpep merged 1 commit into
mainfrom
zero-arg-class-attrs

Conversation

@dpep

@dpep dpep commented Oct 27, 2026

Copy link
Copy Markdown
Owner

Fixes two problems from round 4 of the bug hunt:

  • A zero-arg function in a class body became a method. This regressed in Keep assigned ambiguous functions as values #25. timeout = ambiguous(lambda: 5) has the qualname Config.<lambda>, so it passed the "defined here" check: Config.timeout returned the raw lambda, and Config().timeout raised TypeError. 0.5.1 gave 5 for both. The swap now also requires a positional param to take self.
  • ambiguous(proxy) called the wrapped function 8 times before rejecting it, because isinstance() reads the delegated __class__. ambiguous() now checks type(obj), as _ambiguous_class already does.

The class-body changelog line now says "taking self".

Tests: test_rewrap and the zero-arg cases in test_class_attribute.

@dpep
dpep marked this pull request as ready for review October 27, 2026 03:57
@dpep
dpep merged commit c918595 into main Oct 27, 2026
6 checks passed
@dpep
dpep deleted the zero-arg-class-attrs branch October 27, 2026 03:57
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.

1 participant