Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 357d207

Browse files
potiukCloud Composer Team
authored and
Cloud Composer Team
committedApr 4, 2023
fIx isort problems introduced by recent isort release (#28434)
The recent isort changed their mind on sorting the imports. This change follows the change and bumps isort to latest released version (isort has no install_requires on its own so bumping min version has no effect on other dependencies) This change adds a number of isort:skip_file, isort:off, isort:skips in order to handle a very annoying bug in isort, that no matter how much you try, it sometimes treat "known first party" packages differently - depending on how many files it processes at a time. We should be able to restore it after this bug is fixed: PyCQA/isort#2045 This change also updates the common.sql API to skip them from isort for the very same reason (depending on how many files are modified, the isort order might change. (cherry picked from commit f115b207bc844c10569b2df6fc9acfa32a3c7f41) GitOrigin-RevId: d7db157adf1ad1fc687ce6e203d71fab7f495f25
1 parent 9294e6b commit 357d207

12 files changed

+37
-9
lines changed
 

‎.pre-commit-config.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@ repos:
146146
- --fuzzy-match-generates-todo
147147
files: >
148148
\.cfg$|\.conf$|\.ini$|\.ldif$|\.properties$|\.readthedocs$|\.service$|\.tf$|Dockerfile.*$
149+
- repo: https://github.com/PyCQA/isort
150+
rev: 5.11.2
151+
hooks:
152+
- id: isort
153+
name: Run isort to sort imports in Python files
149154
# Keep version of black in sync wit blacken-docs and pre-commit-hook-names
150155
- repo: https://github.com/psf/black
151156
rev: 22.12.0
@@ -233,11 +238,6 @@ repos:
233238
entry: yamllint -c yamllint-config.yml --strict
234239
types: [yaml]
235240
exclude: ^.*init_git_sync\.template\.yaml$|^.*airflow\.template\.yaml$|^chart/(?:templates|files)/.*\.yaml$|openapi/.*\.yaml$|^\.pre-commit-config\.yaml$|^airflow/_vendor/
236-
- repo: https://github.com/PyCQA/isort
237-
rev: 5.10.1
238-
hooks:
239-
- id: isort
240-
name: Run isort to sort imports in Python files
241241
- repo: https://github.com/pycqa/pydocstyle
242242
rev: 6.1.1
243243
hooks:

‎docker_tests/test_docker_compose_quick_start.py

+4
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,14 @@
2727
from unittest import mock
2828

2929
import requests
30+
31+
# isort:off (needed to workaround isort bug)
3032
from docker_tests.command_utils import run_command
3133
from docker_tests.constants import SOURCE_ROOT
3234
from docker_tests.docker_tests_utils import docker_image
3335

36+
# isort:on (needed to workaround isort bug)
37+
3438
AIRFLOW_WWW_USER_USERNAME = os.environ.get("_AIRFLOW_WWW_USER_USERNAME", "airflow")
3539
AIRFLOW_WWW_USER_PASSWORD = os.environ.get("_AIRFLOW_WWW_USER_PASSWORD", "airflow")
3640
DAG_ID = "example_bash_operator"

‎docker_tests/test_examples_of_prod_image_building.py

+3
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,12 @@
2525
import pytest
2626
import requests
2727

28+
# isort:off (needed to workaround isort bug)
2829
from docker_tests.command_utils import run_command
2930
from docker_tests.constants import SOURCE_ROOT
3031

32+
# isort:on (needed to workaround isort bug)
33+
3134
DOCKER_EXAMPLES_DIR = SOURCE_ROOT / "docs" / "docker-stack" / "docker-examples"
3235

3336

‎docker_tests/test_prod_image.py

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import pytest
2626

27+
# isort:off (needed to workaround isort bug)
2728
from docker_tests.command_utils import run_command
2829
from docker_tests.constants import SOURCE_ROOT
2930
from docker_tests.docker_tests_utils import (
@@ -32,6 +33,8 @@
3233
run_bash_in_docker,
3334
run_python_in_docker,
3435
)
36+
37+
# isort:on (needed to workaround isort bug)
3538
from setup import PREINSTALLED_PROVIDERS
3639

3740
INSTALLED_PROVIDER_PATH = SOURCE_ROOT / "scripts" / "ci" / "installed_providers.txt"

‎docs/build_docs.py

+6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
# KIND, either express or implied. See the License for the
1616
# specific language governing permissions and limitations
1717
# under the License.
18+
"""
19+
Builds documentation and runs spell checking
20+
21+
# isort:skip_file (needed to workaround isort bug)
22+
"""
1823
from __future__ import annotations
1924

2025
import argparse
@@ -33,6 +38,7 @@
3338
from docs.exts.docs_build.github_action_utils import with_group
3439
from docs.exts.docs_build.package_filter import process_package_filters
3540
from docs.exts.docs_build.spelling_checks import SpellingError, display_spelling_error_summary
41+
3642
from rich.console import Console
3743
from tabulate import tabulate
3844

‎docs/exts/docs_build/dev_index_generator.py

+3
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,11 @@
2323

2424
import jinja2
2525

26+
# isort:off (needed to workaround isort bug)
2627
from docs.exts.provider_yaml_utils import load_package_data
2728

29+
# isort:on (needed to workaround isort bug)
30+
2831
CURRENT_DIR = os.path.abspath(os.path.dirname(__file__))
2932
DOCS_DIR = os.path.abspath(os.path.join(CURRENT_DIR, os.pardir, os.pardir))
3033
BUILD_DIR = os.path.abspath(os.path.join(DOCS_DIR, "_build"))

‎docs/exts/docs_build/errors.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
from rich.console import Console
2424

2525
from airflow.utils.code_utils import prepare_code_snippet
26-
from docs.exts.docs_build.code_utils import CONSOLE_WIDTH
26+
27+
from docs.exts.docs_build.code_utils import CONSOLE_WIDTH # isort:skip (needed to workaround isort bug)
28+
2729

2830
CURRENT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__)))
2931
DOCS_DIR = os.path.abspath(os.path.join(CURRENT_DIR, os.pardir, os.pardir))

‎docs/publish_docs.py

+3
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,13 @@
2121
import argparse
2222
import os
2323

24+
# isort:off (needed to workaround isort bug)
2425
from exts.docs_build.docs_builder import AirflowDocsBuilder
2526
from exts.docs_build.package_filter import process_package_filters
2627
from exts.provider_yaml_utils import load_package_data
2728

29+
# isort:on (needed to workaround isort bug)
30+
2831
AIRFLOW_SITE_DIR = os.environ.get("AIRFLOW_SITE_DIRECTORY")
2932

3033

‎kubernetes_tests/test_kubernetes_executor.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
import pytest
2222

23-
from kubernetes_tests.test_base import EXECUTOR, TestBase
23+
from kubernetes_tests.test_base import EXECUTOR, TestBase # isort:skip (needed to workaround isort bug)
2424

2525

2626
@pytest.mark.skipif(EXECUTOR != "KubernetesExecutor", reason="Only runs on KubernetesExecutor")

‎kubernetes_tests/test_other_executors.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
import pytest
2222

23-
from kubernetes_tests.test_base import EXECUTOR, TestBase
23+
from kubernetes_tests.test_base import EXECUTOR, TestBase # isort:skip (needed to workaround isort bug)
2424

2525

2626
# These tests are here because only KubernetesExecutor can run the tests in

‎pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,6 @@ known_first_party = ["airflow", "airflow_breeze", "docker_tests", "docs", "kuber
3535
# The test_python.py is needed because adding __future__.annotations breaks runtime checks that are
3636
# needed for the test to work
3737
skip = ["build", ".tox", "venv", "tests/decorators/test_python.py"]
38+
lines_between_types = 0
3839
skip_glob = ["*.pyi"]
3940
profile = "black"

‎setup.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,10 @@ def write_version(filename: str = str(AIRFLOW_SOURCES_ROOT / "airflow" / "git_ve
377377
"freezegun",
378378
"gitpython",
379379
"ipdb",
380-
"isort",
380+
# make sure that we are using stable sorting order from 5.* version (some changes were introduced
381+
# in 5.11.3. Black is not compatible yet, so we need to limit isort
382+
# we can remove the limit when black and isort agree on the order
383+
"isort==5.11.2",
381384
"jira",
382385
"jsondiff",
383386
"mongomock",

0 commit comments

Comments
 (0)