diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-02-18 10:05:12 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-05-20 14:19:02 -0400 |
commit | a463b1109abb60fc85f8356f30c0351a4e2ed71e (patch) | |
tree | de8f96b7bce319fc0f19f56b302202ea3e4e91db /lib/sqlalchemy/util/typing.py | |
parent | 9e7bed9df601ead02fd96bf2fc787b23b536d2d6 (diff) | |
download | sqlalchemy-a463b1109abb60fc85f8356f30c0351a4e2ed71e.tar.gz |
implement dataclass_transforms
Implement a new means of creating a mapped dataclass where
instead of applying the `@dataclass` decorator distinctly,
the declarative process itself can create the dataclass.
MapperProperty and MappedColumn objects themselves take
the place of the dataclasses.Field object when constructing
the class.
The overall approach is made possible at the typing level
using pep-681 dataclass transforms [1].
This new approach should be able to completely supersede the
previous "dataclasses" approach of embedding metadata into
Field() objects, which remains a mutually exclusive declarative
setup style (mixing them introduces new issues that are not worth
solving).
[1] https://peps.python.org/pep-0681/#transform-descriptor-types-example
Fixes: #7642
Change-Id: I6ba88a87c5df38270317b4faf085904d91c8a63c
Diffstat (limited to 'lib/sqlalchemy/util/typing.py')
-rw-r--r-- | lib/sqlalchemy/util/typing.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/sqlalchemy/util/typing.py b/lib/sqlalchemy/util/typing.py index 44e26f609..454de100b 100644 --- a/lib/sqlalchemy/util/typing.py +++ b/lib/sqlalchemy/util/typing.py @@ -23,6 +23,14 @@ from typing_extensions import NotRequired as NotRequired # noqa: F401 from . import compat + +# more zimports issues +if True: + from typing_extensions import ( # noqa: F401 + dataclass_transform as dataclass_transform, + ) + + _T = TypeVar("_T", bound=Any) _KT = TypeVar("_KT") _KT_co = TypeVar("_KT_co", covariant=True) |