Hi Avi, all,
we had a bit of a discussion about this and don't know if this is very
controversal... but: Python 3.9 will run out of support in September.
How about if we drop support early in 3.1 so that we migrate main to
3.10 and by this remove the deadlock?
Jens
On 07.05.25 16:48, Abhishek Bhakat wrote:
Hi All,
I've hit a little deadlock.
We want to use SQLAlchemy 2.x ORM typing (Mapped[...] =
mapped_column(...)) with
PEP 604 union types (int | None) in model annotations and must support
Python 3.9 (which does not support int | None at runtime).
We do not want to use Optional[...] (ruff UP007 is enforced). And, we
already have from __future__ import annotations everywhere. And getting
error like:
sqlalchemy.orm.exc.MappedAnnotationError: Could not resolve all types within
mapped annotation: "Mapped[int | None]"
TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'
mypy/ruff are not happy with Mapped[Optional[int]] (*ruff UP007*), and
SQLAlchemy 2.x cannot parse Mapped[int | None] on Python 3.9.
With from __future__ import annotations, SQLAlchemy stores the annotation
as a string. At runtime, it tries to eval() the string in the module's
namespace. On Python 3.9, eval("int | None") fails.
Need help and suggestion on how shall I proceed?
Thanks,
Avi
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@airflow.apache.org
For additional commands, e-mail: dev-h...@airflow.apache.org