Skip to content

Fix runtime signatures of bound cached methods - #812

Open
bbbbbbbbbbb114 wants to merge 3 commits into
aio-libs:masterfrom
bbbbbbbbbbb114:gjc/bound-method-signature
Open

bbbbbbbbbbb114 wants to merge 3 commits into
aio-libs:masterfrom
bbbbbbbbbbb114:gjc/bound-method-signature

Conversation

@bbbbbbbbbbb114

Copy link
Copy Markdown

What do these changes do?

Fix a runtime introspection mismatch when a caching decorator wraps an instance method. The method call works, but the exposed metadata still describes an unbound function.

For an ordinary bound method, inspect.signature(service.plain) does not include self. Previously, inspect.signature(service.cached) still included it. Also, bypassing the cache required passing the receiver explicitly as service.cached.__wrapped__(service, 7).

Use the standard-library types.MethodType to bind the proxy's original __wrapped__ function to the current receiver.

Are there changes in behavior for the user?

  • inspect.signature(service.cached) now matches the ordinary bound method's signature, without the extra self.
  • service.cached.__wrapped__(7) calls the original method without requiring the receiver again.
  • The change is limited to runtime introspection of bound instance methods. Cache hits, key computation and class-level descriptor logic are unchanged, and it does not introduce eager signature computation.

Related issue number

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes

Copilot AI balanced review requested due to automatic review settings October 31, 2026 08:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@greptile-apps

greptile-apps Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5 Tier: apex

[Low impact] The PR appears safe to merge; no outstanding findings remain.

Reviews (3) · Last reviewed commit: "Keep invalid signature metadata from blo..." · Reviewed by Greptile

Comment thread async_lru/__init__.py Resolved
Comment thread async_lru/__init__.py Resolved

This branch has not been deployed

No deployments
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.

2 participants