From: Mike Bayer Date: Fri, 28 Apr 2023 03:00:18 +0000 (-0400) Subject: adjust fwd_ref logic X-Git-Tag: rel_2_0_13~17^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d9be22044d251c047b6306e767b2537c0ee12709;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git adjust fwd_ref logic Fixed issue where ORM Annotated Declarative would not resolve forward references correctly in all cases; in particular, when using ``from __future__ import annotations`` in combination with Pydantic dataclasses. Change-Id: If643c9a4ac7e217d4cb3a7d09b96cfd49432c44e References: #9717 --- diff --git a/doc/build/changelog/unreleased_20/9717.rst b/doc/build/changelog/unreleased_20/9717.rst new file mode 100644 index 0000000000..d70ffe17a8 --- /dev/null +++ b/doc/build/changelog/unreleased_20/9717.rst @@ -0,0 +1,8 @@ +.. change:: + :tags: bug, orm + :tickets: 9717 + + Fixed issue where ORM Annotated Declarative would not resolve forward + references correctly in all cases; in particular, when using + ``from __future__ import annotations`` in combination with Pydantic + dataclasses. diff --git a/lib/sqlalchemy/util/typing.py b/lib/sqlalchemy/util/typing.py index 9c38ae3443..3ac67aad9a 100644 --- a/lib/sqlalchemy/util/typing.py +++ b/lib/sqlalchemy/util/typing.py @@ -146,7 +146,7 @@ def de_stringify_annotation( original_annotation = annotation - if is_fwd_ref(annotation) and not annotation.__forward_evaluated__: + if is_fwd_ref(annotation): annotation = annotation.__forward_arg__ if isinstance(annotation, str):