Skip to content

Preserve Value's runtime annotation namespace - #51

Open
Quinnod345 wants to merge 1 commit into
python-trio:mainfrom
Quinnod345:fix/value-runtime-annotations
Open

Quinnod345 wants to merge 1 commit into
python-trio:mainfrom
Quinnod345:fix/value-runtime-annotations

Conversation

@Quinnod345

Copy link
Copy Markdown

After import outcome, typing.get_type_hints(outcome.Value) raises NameError for ValueT. attr.resolve_types(outcome.Value) fails for the same reason where that API is available: metadata normalization moves the class to outcome, but its postponed field annotation still needs the type variable from outcome._impl.

Bind that exact existing type variable in the lookup namespace. The seven-name __all__, public object identities and module names remain intact. Add focused regressions, preservation controls and a bugfix fragment.

Local macOS validation:

  • The identical focused regression fails before and passes after on Python 3.8/3.11 with attrs 19.2.0 and Python 3.13/3.14 with attrs 26.1.0. Only the unavailable attrs resolver is skipped on the minimum dependency. Separate fresh-process resolver runs confirm the result.
  • Full suites pass 15 tests on current attrs, or 14 with one skip on minimum attrs.
  • YAPF 0.20.1, isort, Mypy and Pyright pass. Configured source/test statement and branch coverage is 100%, with the project's exclusions retained.
  • The sdist and wheel build; installed-wheel tests and reload/identity checks pass on Python 3.13/current attrs and Python 3.8/minimum attrs. The Towncrier draft renders the fragment.

I maintain Ponder. Its review flagged this case; I reproduced it and implemented the fix.

Public metadata normalization moves Value to outcome, while its postponed
field annotation still resolves ValueT through that module. Bind the exact
existing type variable so default typing and attrs class introspection
works without replacing public objects or changing the export list.

Add focused regressions and a user-visible bugfix fragment. The identical
regression fails before and passes after on the checked minimum and current
Python/attrs combinations; native suites, formatting, type checks, configured
coverage, builds and installed-wheel checks pass locally.
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