Skip to content

Commit

Permalink
Bump Ruff to 0.8.0 (apache#44287)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexWaygood authored Nov 22, 2024
1 parent fedfaa7 commit ab38d01
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ repos:
types_or: [python, pyi]
args: [--fix]
require_serial: true
additional_dependencies: ["ruff==0.7.3"]
additional_dependencies: ["ruff==0.8.0"]
exclude: ^.*/.*_vendor/|^tests/dags/test_imports.py|^performance/tests/test_.*.py
- id: ruff-format
name: Run 'ruff format'
Expand All @@ -370,7 +370,7 @@ repos:
types_or: [python, pyi]
args: []
require_serial: true
additional_dependencies: ["ruff==0.7.3"]
additional_dependencies: ["ruff==0.8.0"]
exclude: ^.*/.*_vendor/|^tests/dags/test_imports.py$
- id: replace-bad-characters
name: Replace bad characters
Expand Down
2 changes: 1 addition & 1 deletion airflow/models/baseoperator.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@

# Todo: AIP-44: Once we get rid of AIP-44 we can remove this. But without this here pydantic fails to resolve
# types for serialization
from airflow.utils.task_group import TaskGroup # noqa: TCH001
from airflow.utils.task_group import TaskGroup # noqa: TC001

TaskPreExecuteHook = Callable[[Context], None]
TaskPostExecuteHook = Callable[[Context, Any], None]
Expand Down
4 changes: 2 additions & 2 deletions airflow/serialization/serialized_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@

HAS_KUBERNETES: bool
try:
from kubernetes.client import models as k8s # noqa: TCH004
from kubernetes.client import models as k8s # noqa: TC004

from airflow.providers.cncf.kubernetes.pod_generator import PodGenerator # noqa: TCH004
from airflow.providers.cncf.kubernetes.pod_generator import PodGenerator # noqa: TC004
except ImportError:
pass

Expand Down
2 changes: 1 addition & 1 deletion dev/breeze/src/airflow_breeze/utils/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class Output(NamedTuple):

@property
def file(self) -> TextIO:
return open(self.file_name, "a+t")
return open(self.file_name, "a+")

@property
def escaped_title(self) -> str:
Expand Down
2 changes: 1 addition & 1 deletion hatch_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@
],
"devel-static-checks": [
"black>=23.12.0",
"ruff==0.7.3",
"ruff==0.8.0",
"yamllint>=1.33.0",
],
"devel-tests": [
Expand Down
15 changes: 7 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ extend-select = [
"UP", # Pyupgrade
"ASYNC", # subset of flake8-async rules
"ISC", # Checks for implicit literal string concatenation (auto-fixable)
"TCH", # Rules around TYPE_CHECKING blocks
"TC", # Rules around TYPE_CHECKING blocks
"G", # flake8-logging-format rules
"LOG", # flake8-logging rules, most of them autofixable
"PT", # flake8-pytest-style rules
Expand Down Expand Up @@ -260,8 +260,7 @@ ignore = [
"D203",
"D212", # Conflicts with D213. Both can not be enabled.
"E731", # Do not assign a lambda expression, use a def
"TCH003", # Do not move imports from stdlib to TYPE_CHECKING block
"PT004", # Fixture does not return anything, add leading underscore
"TC003", # Do not move imports from stdlib to TYPE_CHECKING block
"PT006", # Wrong type of names in @pytest.mark.parametrize
"PT007", # Wrong type of values in @pytest.mark.parametrize
"PT013", # silly rule prohibiting e.g. `from pytest import param`
Expand Down Expand Up @@ -313,8 +312,8 @@ section-order = [
testing = ["dev", "providers.tests", "task_sdk.tests", "tests_common", "tests"]

[tool.ruff.lint.extend-per-file-ignores]
"airflow/__init__.py" = ["F401", "TCH004", "I002"]
"airflow/models/__init__.py" = ["F401", "TCH004"]
"airflow/__init__.py" = ["F401", "TC004", "I002"]
"airflow/models/__init__.py" = ["F401", "TC004"]
"airflow/models/sqla_models.py" = ["F401"]
"providers/src/airflow/providers/__init__.py" = ["I002"]
"providers/src/airflow/__init__.py" = ["I002"]
Expand All @@ -326,12 +325,12 @@ testing = ["dev", "providers.tests", "task_sdk.tests", "tests_common", "tests"]
# The Pydantic representations of SqlAlchemy Models are not parsed well with Pydantic
# when __future__.annotations is used so we need to skip them from upgrading
# Pydantic also require models to be imported during execution
"airflow/serialization/pydantic/*.py" = ["I002", "UP007", "TCH001"]
"airflow/serialization/pydantic/*.py" = ["I002", "UP007", "TC001"]

# Failing to detect types and functions used in `Annotated[...]` syntax as required at runtime.
# Annotated is central for FastAPI dependency injection, skipping rules for FastAPI folders.
"airflow/api_fastapi/*" = ["TCH001", "TCH002"]
"tests/api_fastapi/*" = ["TCH001", "TCH002"]
"airflow/api_fastapi/*" = ["TC001", "TC002"]
"tests/api_fastapi/*" = ["T001", "TC002"]

# Ignore pydoc style from these
"*.pyi" = ["D"]
Expand Down
4 changes: 2 additions & 2 deletions task_sdk/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ namespace-packages = ["src/airflow"]
# Pycharm barfs if this "stub" file has future imports
"src/airflow/__init__.py" = ["I002"]

"src/airflow/sdk/__init__.py" = ["TCH004"]
"src/airflow/sdk/__init__.py" = ["TC004"]

# msgspec needs types for annotations to be defined, even with future
# annotations, so disable the "type check only import" for these files
"src/airflow/sdk/api/datamodels/*.py" = ["TCH001"]
"src/airflow/sdk/api/datamodels/*.py" = ["TC001"]

# Only the public API should _require_ docstrings on classes
"!src/airflow/sdk/definitions/*" = ["D101"]
Expand Down

0 comments on commit ab38d01

Please sign in to comment.