Re: [sqlalchemy] Using Mapped[str | None]

2022-08-31 Thread Mike Bayer
absolutely, there's no reason str | None shouldn't work also On Wed, Aug 31, 2022, at 8:26 PM, Peter Schutt wrote: > Thanks Mike, I will submit at next opportunity. > > I believe Union[str, None] is fine, just that pep 604 brought in UnionType in > 3.10+ which represents the "str | None" union

Re: [sqlalchemy] Using Mapped[str | None]

2022-08-31 Thread Peter Schutt
Thanks Mike, I will submit at next opportunity. I believe Union[str, None] is fine, just that pep 604 brought in UnionType in 3.10+ which represents the "str | None" union type, but I'll stick more detail in the issue. Not having to import Optional or Union everywhere is one of the nice

[sqlalchemy] testing patterns with sqlalchemy 2.0

2022-08-31 Thread Chris Withers
Hi All, Are there any libraries (or anything in sqlalchemy itself!) that cover the pattern of running unit tests in against a database such that each test gets its own sterile environment in which to run? Postgres, if it helps. I've done some stuff with running in a subtransaction and rolling

Re: [sqlalchemy] Using Mapped[str | None]

2022-08-31 Thread Mike Bayer
On Wed, Aug 31, 2022, at 5:00 AM, Peter Schutt wrote: > Hi, > > I've been using 2.0 from main and notice that annotating an attribute with > `mapped[str | None]` raises with: > > sqlalchemy.exc.ArgumentError: Could not locate SQLAlchemy Core type for > Python type: str | None > > > I've

[sqlalchemy] Using Mapped[str | None]

2022-08-31 Thread Peter Schutt
Hi, I've been using 2.0 from main and notice that annotating an attribute with `mapped[str | None]` raises with: sqlalchemy.exc.ArgumentError: Could not locate SQLAlchemy Core type for Python type: str | None I've been able to get it to work with a couple of mods in util.typing and