Skip to content

Fix arginfo cache fallback for unhashable callables - #80

Merged
henri-hulski merged 1 commit into
morepath:masterfrom
harbinresearcher:codex/inspect-unhashable-callables
Oct 17, 2026
Merged

henri-hulski merged 1 commit into
morepath:masterfrom
harbinresearcher:codex/inspect-unhashable-callables

Conversation

@harbinresearcher

Copy link
Copy Markdown
Contributor

Fixes #79.

arginfo() raises TypeError for ordinary unhashable callable instances (for example, dataclass functors) before reaching its existing bound-__call__ cache fallback. arginfo.is_cached() fails on the same initial instance lookup.

Treat an unhashable instance key as a reason to use that existing fallback. Keep the current cache keys and result reuse, and clarify the cache docstring. This also restores the documented None result for unhashable noncallables. Generic-function registration is outside this change.

Four new regression cases cover the bound signature, defaults, keyword-only arguments, annotations, cache state and identity, and list/dict noncallables. All four fail before the fix.

Validation:

  • Windows CPython 3.12.14: full suite 194 -> 198 passed; configured statement coverage remains 100%.
  • Linux CPython 3.11.17 and 3.14.8: full suite 194 -> 198 passed on each.
  • Both pristine and patched Linux trees pass the project's tox -e py311,py314,coverage,lint,docs,mypy,pyright,perf, including the 100% coverage gate, Ruff check/format, strict Sphinx HTML/doctests, and both type checkers' configured 3.11-3.15 targets.
  • Isolated sdist/wheel build succeeds; the installed wheel passes all 61 arginfo tests.
  • Independent automated read-only review found no actionable issues. PyPy, macOS, and the remaining runtime matrix were not run locally.

Disclosure: this contribution was investigated, implemented, tested, and reviewed autonomously with AI under the contributor's authorization. The independent review was also automated, not human approval.

@henri-hulski henri-hulski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me. Thank you for the contribution.

@henri-hulski
henri-hulski merged commit 3a341a1 into morepath:master Oct 17, 2026
6 checks passed
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.

arginfo rejects unhashable callable instances before its bound-method cache fallback

2 participants