This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 42167990de Add __future__.annotations automatically by isort (#26383)
42167990de is described below

commit 42167990de974e66d0b568f90992fbbe7073782b
Author: Jarek Potiuk <[email protected]>
AuthorDate: Wed Sep 14 12:19:17 2022 +0200

    Add __future__.annotations automatically by isort (#26383)
    
    This is a follow up after #26289 and 26290 to automatically add
    __future__.annotations import to all new files (except empty __init__).
    
    Also the isort configureation is moved to pyproject toml to be
    consistent across manual and pre-commit runs of isort
---
 .pre-commit-config.yaml                                 | 14 +-------------
 airflow/migrations/versions/0009_1_6_0_dagrun_config.py |  2 ++
 dev/airflow-github                                      | 13 +++++++------
 dev/airflow-license                                     |  2 ++
 docs/apache-airflow/img/airflow_erd.sha256              |  2 +-
 pyproject.toml                                          | 12 ++++++++++++
 scripts/ci/runners/sync_authors.py                      |  2 ++
 setup.cfg                                               | 12 ------------
 tests/task/__init__.py                                  |  2 ++
 9 files changed, 29 insertions(+), 32 deletions(-)

diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index eda184522d..60da9658e3 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -219,7 +219,7 @@ repos:
         # __future__ annotations, so it should be left without automated 
upgrade
         # BaseOperator is disabled because replacing ClassVar[List[Type with 
corresponding list/type causes the attr to fail
         # see 
https://github.com/apache/airflow/pull/26290#issuecomment-1246014807
-        exclude: 
^airflow/_vendor/|^airflow/providers/google/cloud/hooks/gcs.py$|^test/decorators/test_python.py$|^airflow/models/baseoperator.py$
+        exclude: 
^airflow/_vendor/|^airflow/providers/google/cloud/hooks/gcs.py$|^tests/decorators/test_python.py$|^airflow/models/baseoperator.py$
   - repo: https://github.com/pre-commit/pygrep-hooks
     rev: v1.9.0
     hooks:
@@ -242,18 +242,6 @@ repos:
     hooks:
       - id: isort
         name: Run isort to sort imports in Python files
-        files: \.py$|\.pyi$
-        # To keep consistent with the global isort skip config defined in 
setup.cfg
-        exclude: ^airflow/_vendor/|^build/.*$|^venv/.*$|^\.tox/.*$
-        args:
-          # These -p options are duplicated to known_first_party in setup.cfg,
-          # Please keep these in sync for now. (See comments there for 
details.)
-          - -p=airflow
-          - -p=airflow_breeze
-          - -p=docker_tests
-          - -p=docs
-          - -p=kubernetes_tests
-          - -p=tests
   - repo: https://github.com/pycqa/pydocstyle
     rev: 6.1.1
     hooks:
diff --git a/airflow/migrations/versions/0009_1_6_0_dagrun_config.py 
b/airflow/migrations/versions/0009_1_6_0_dagrun_config.py
index 4c1ced0b9d..365af4bc6e 100644
--- a/airflow/migrations/versions/0009_1_6_0_dagrun_config.py
+++ b/airflow/migrations/versions/0009_1_6_0_dagrun_config.py
@@ -22,6 +22,8 @@ Revises: 2e541a1dcfed
 Create Date: 2015-10-29 08:36:31.726728
 
 """
+from __future__ import annotations
+
 import sqlalchemy as sa
 from alembic import op
 
diff --git a/dev/airflow-github b/dev/airflow-github
index 6a11505496..d9e4afbe77 100755
--- a/dev/airflow-github
+++ b/dev/airflow-github
@@ -20,10 +20,11 @@
 # This tool is based on the Spark merge_spark_pr script:
 # https://github.com/apache/spark/blob/master/dev/merge_spark_pr.py
 
+from __future__ import annotations
+
 import re
 import sys
 from collections import Counter, defaultdict
-from typing import List, Optional
 
 import git
 import rich_click as click
@@ -70,7 +71,7 @@ def get_issue_type(issue):
     return issue_type
 
 
-def get_commit_in_main_associated_with_pr(repo: git.Repo, issue: Issue) -> 
Optional[str]:
+def get_commit_in_main_associated_with_pr(repo: git.Repo, issue: Issue) -> str 
| None:
     """For a PR, find the associated merged commit & return its SHA"""
     if issue.pull_request:
         commit = repo.git.log(f"--grep=#{issue.number}", "origin/main", 
"--format=%H")
@@ -84,7 +85,7 @@ def get_commit_in_main_associated_with_pr(repo: git.Repo, 
issue: Issue) -> Optio
     return None
 
 
-def is_cherrypicked(repo: git.Repo, issue: Issue, previous_version: 
Optional[str] = None) -> bool:
+def is_cherrypicked(repo: git.Repo, issue: Issue, previous_version: str | None 
= None) -> bool:
     """Check if a given issue is cherry-picked in the current branch or not"""
     log_args = ['--format=%H', f"--grep=#{issue.number}"]
     if previous_version:
@@ -100,12 +101,12 @@ def is_pr(issue: Issue) -> bool:
     return "apache/airflow/pull/" in issue.html_url
 
 
-def files_touched(repo, commit_id: str) -> List[str]:
+def files_touched(repo, commit_id: str) -> list[str]:
     real_commit = repo.commit(commit_id)
     return real_commit.stats.files.keys()
 
 
-def is_core_commit(files: List[str]) -> bool:
+def is_core_commit(files: list[str]) -> bool:
     # We list out things that _aren't_ core files,
     # and we want to know if the commit changes anything
     # outside of these designated-non-core files
@@ -219,7 +220,7 @@ def compare(target_version, github_token, 
previous_version=None, show_uncherrypi
     repo = git.Repo(".", search_parent_directories=True)
 
     github_handler = Github(github_token)
-    milestone_issues: List[Issue] = list(
+    milestone_issues: list[Issue] = list(
         github_handler.search_issues(f"repo:apache/airflow milestone:\"Airflow 
{target_version}\"")
     )
 
diff --git a/dev/airflow-license b/dev/airflow-license
index 6007612342..a38edc8a2f 100755
--- a/dev/airflow-license
+++ b/dev/airflow-license
@@ -17,6 +17,8 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import annotations
+
 import os
 import re
 import string
diff --git a/docs/apache-airflow/img/airflow_erd.sha256 
b/docs/apache-airflow/img/airflow_erd.sha256
index c4e1cb00b1..eab880ad31 100644
--- a/docs/apache-airflow/img/airflow_erd.sha256
+++ b/docs/apache-airflow/img/airflow_erd.sha256
@@ -1 +1 @@
-866390aad1d155c75b4283c4d50ff56fb1f210f21dcd0e0955984bd08f26ac5c
\ No newline at end of file
+b3211bf16ef6ae93fc4a4cfeb2acffc0e2f3a8f476d76148d543f2751aff2c5d
\ No newline at end of file
diff --git a/pyproject.toml b/pyproject.toml
index 3fdc6a39ef..0f6a2dd230 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -26,3 +26,15 @@ skip-string-normalization = true
 [build-system]
 requires = ['setuptools==63.4.3']
 build-backend = "setuptools.build_meta"
+[tool.isort]
+add_imports = ["from __future__ import annotations"]
+append_only = true
+line_length = 110
+combine_as_imports = true
+default_section = "THIRDPARTY"
+known_first_party = ["airflow", "airflow_breeze", "docker_tests", "docs", 
"kubernetes_tests", "tests"]
+# The test_python.py is needed because adding __future__.annotations breaks 
runtime checks that are
+# needed for the test to work
+skip = ["build", ".tox", "venv", "tests/decorators/test_python.py"]
+skip_glob = ["*.pyi"]
+profile = "black"
diff --git a/scripts/ci/runners/sync_authors.py 
b/scripts/ci/runners/sync_authors.py
index 8fc9717e5b..0fecf4b6a5 100644
--- a/scripts/ci/runners/sync_authors.py
+++ b/scripts/ci/runners/sync_authors.py
@@ -17,6 +17,8 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import annotations
+
 import re
 
 import requests
diff --git a/setup.cfg b/setup.cfg
index 986eb13f30..f558826dc6 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -202,15 +202,3 @@ ignore_errors = True
 # Most of them don't but even if they do, it does not matter
 [mypy-google.cloud.*]
 no_implicit_optional = False
-
-[isort]
-line_length=110
-combine_as_imports = true
-default_section = THIRDPARTY
-# This is duplicated with arguments in .pre-commit-config.yaml because isort is
-# having some issues picking up these config files. Please keep these in sync
-# for now and track the isort issue: https://github.com/PyCQA/isort/issues/1889
-known_first_party = 
airflow,airflow_breeze,docker_tests,docs,kubernetes_tests,tests
-# Need to be consistent with the exclude config defined in 
pre-commit-config.yaml
-skip = build,.tox,venv
-profile = black
diff --git a/tests/task/__init__.py b/tests/task/__init__.py
index 9e7116e7f7..865dd751b4 100644
--- a/tests/task/__init__.py
+++ b/tests/task/__init__.py
@@ -16,4 +16,6 @@
 # specific language governing permissions and limitations
 # under the License.
 # flake8: noqa
+from __future__ import annotations
+
 from .task_runner import *

Reply via email to