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 ergonomic improvements to typing of late. Cheers:) On Wednesday, 31 August 2022 at 23:32:37 UTC+10 Mike Bayer wrote: > > > 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 been able to get it to work with a couple of mods in util.typing and > orm.properties and the basic tox run doesn't show any failures. > > I've searched both GH issues and in the group here for that exception > string without result, is this worth opening an issue for? > > > you should be using Mapped[Optional[str]] ; that said if Mapped[Union[str, > None]] and/or Mapped[str | None] is not being parsed then yes this is > worthy of a bug report for 2.0. > > > > Thanks! > > > > -- > SQLAlchemy - > The Python SQL Toolkit and Object Relational Mapper > > http://www.sqlalchemy.org/ > > To post example code, please provide an MCVE: Minimal, Complete, and > Verifiable Example. See http://stackoverflow.com/help/mcve for a full > description. > --- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sqlalchemy+...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/sqlalchemy/32e27c41-659b-4748-8ef7-3255ff13bf71n%40googlegroups.com > > <https://groups.google.com/d/msgid/sqlalchemy/32e27c41-659b-4748-8ef7-3255ff13bf71n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > > -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/e0dd3f91-1b01-4bce-a921-0c694f846891n%40googlegroups.com.