-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
typing.Annotated fails for functions returning UUIDs #115165
Labels
Comments
Thanks for the report! Arguably there are two bugs here:
|
dave-shawley
added a commit
to dave-shawley/cpython
that referenced
this issue
Feb 9, 2024
Update news blurb for pythongh-115165
dave-shawley
added a commit
to dave-shawley/cpython
that referenced
this issue
Feb 9, 2024
Add comment justifying `except Exception`
dave-shawley
added a commit
to dave-shawley/cpython
that referenced
this issue
Feb 9, 2024
Renamed test_annotated_callable_returning_immutable to test_instantiate_immutable and moved it near the other instantiation tests.
dave-shawley
added a commit
to dave-shawley/cpython
that referenced
this issue
Feb 9, 2024
Add a test for generic instantiation that trips the same __setattr__ exception in Annotation.
AlexWaygood
pushed a commit
that referenced
this issue
Feb 9, 2024
The return value from an annotated callable can raise any exception from __setattr__ for the `__orig_class__` property.
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this issue
Feb 9, 2024
…-115213) The return value from an annotated callable can raise any exception from __setattr__ for the `__orig_class__` property. (cherry picked from commit 5643856) Co-authored-by: dave-shawley <[email protected]>
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this issue
Feb 9, 2024
…-115213) The return value from an annotated callable can raise any exception from __setattr__ for the `__orig_class__` property. (cherry picked from commit 5643856) Co-authored-by: dave-shawley <[email protected]>
This was referenced Feb 9, 2024
AlexWaygood
pushed a commit
that referenced
this issue
Feb 9, 2024
…) (#115227) gh-115165: Fix `typing.Annotated` for immutable types (GH-115213) The return value from an annotated callable can raise any exception from __setattr__ for the `__orig_class__` property. (cherry picked from commit 5643856) Co-authored-by: dave-shawley <[email protected]>
AlexWaygood
pushed a commit
that referenced
this issue
Feb 9, 2024
…) (#115228) gh-115165: Fix `typing.Annotated` for immutable types (GH-115213) The return value from an annotated callable can raise any exception from __setattr__ for the `__orig_class__` property. (cherry picked from commit 5643856) Co-authored-by: dave-shawley <[email protected]>
Thanks for the report, and the fix! |
fsc-eriker
pushed a commit
to fsc-eriker/cpython
that referenced
this issue
Feb 14, 2024
…15213) The return value from an annotated callable can raise any exception from __setattr__ for the `__orig_class__` property.
AlexWaygood
pushed a commit
to AlexWaygood/cpython
that referenced
this issue
Feb 22, 2024
The return value from an annotated callable can raise any exception from __setattr__ for the `__orig_class__` property.
dave-shawley
added a commit
to dave-shawley/pydantic-tornado
that referenced
this issue
Apr 1, 2024
Note that `typing.Annotated[uuid.UUID, ...]` doesn't work currently so I created a helper class `routing._UUID` that works around the defect. This will be fixed in 3.12.3 when it is released. I added an ignore statement for `ruff check` to allow access to internal names inside of tests. Otherwise testing `_UUID` required too many `noqa` comment directives for me. python/cpython#115165
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Bug report
Bug description:
typing.Annotated
tries to set an attribute on the return value of calling an annotated callable. This fails when the returned object is immutable. I believe that addingTypeError
to theexcept
clause intyping. _BaseGenericAlias.__call__
will fix the problem. I'm not sure if there are more cases of the same pattern or not.cpython/Lib/typing.py
Lines 1128 to 1131 in 17689e3
Example
Result
CPython versions tested on:
3.9, 3.10, 3.11, 3.12
Operating systems tested on:
macOS
Linked PRs
typing.Annotated
for immutable types (GH-115213) #115227typing.Annotated
for immutable types (GH-115213) #115228The text was updated successfully, but these errors were encountered: