Hey everyone.

I just completed merging and cherry-picking (pending test success) the
`__future__.annotations` change (PEP-563) to v2-4-test branch - Airflow
2.4.0 will be released with those included.

I also merged a pre-commit isort change that will automatically add `from
__future__ import annotations` import and we should use the new Python 3.9+
style of imports all over the Airflow code base.

This means few things:

* no more from typing import (List, Dict, Tuple….) - instead list, dict
tuple can be used directly without imports when specifying type

* no more need to “quote” classes that have just been added or are added
via “if TYPE_CHECKING”. For example

def execute(self, context: 'Context') -> None:

should be simply:

def execute(self, context: Context) -> None:

* no need for Optional any more. For example instead of Optional[str] you
can use str | None

Our pre-commits should automatically upgrade your code if you still use the
old style which is also a nice way to quickly learn the Python 3.9+ syntax
for typing.

The discussion in devlist was here:
https://lists.apache.org/thread/81fr042s5d3v17v83bpo24tnrr2pp0fp
The (slightly sped up) lazy consensus call:
https://lists.apache.org/thread/l74nvjh8tgbtojllhwkcn7f8mfnlz4jq

Thanks Ash and TP for help with those!.

There are still a few exclusions, and TP attempts to workaround some of the
limitations of pyupgrade as follow-up so there might be one more commit to
follow.

J.

Reply via email to