Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 88 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -686,8 +686,8 @@ known-first-party = ["airflow"]
testing = ["dev", "providers.tests", "tests_common", "tests", "system", "unit", "integration"]

[tool.ruff.lint.extend-per-file-ignores]
"airflow-core/src/airflow/__init__.py" = ["F401", "TC004", "I002"]
"airflow-core/src/airflow/models/__init__.py" = ["F401", "TC004"]
"airflow-core/src/airflow/__init__.py" = ["F401", "TC004", "I002", "TID251"]
"airflow-core/src/airflow/models/__init__.py" = ["F401", "TC004", "TID251"]
"airflow-core/src/airflow/models/sqla_models.py" = ["F401"]
"airflow-core/src/airflow/cli/api/datamodels/_generated.py" = ["UP007", "D101", "D200"]

Expand Down Expand Up @@ -802,6 +802,89 @@ testing = ["dev", "providers.tests", "tests_common", "tests", "system", "unit",
# mechanism and whole .pyi is really "type-checking" only
"providers/common/sql/src/airflow/providers/common/sql/hooks/sql.pyi" = ["TID253"]

# Example dags will be using imports from task SDK
"airflow-core/src/airflow/example_dags/*" = ["TID251"]

# devel-common has test utilities, ok to have SDK imports here
"devel-common/**" = ["TID251"]

# Allow providers to import from Task SDK because they are consumers of the task SDK
"providers/**" = ["TID251"]

#Ideally, we shouldn't have any imports from airflow-core in the airflow-core tests, but should be OK for now
"airflow-core/tests/**" = ["TID251"]

# TODO: check usages here, suspicious about these
"scripts/**" = ["TID251"]
"dev/**" = ["TID251"]
"performance/**" = ["TID251"]
"kubernetes-tests/tests/kubernetes_tests/test_kubernetes_pod_operator.py" = ["TID251"]

# Temporarily allow existing SDK imports in core files while preventing new ones
# TODO: These files need to be refactored to remove SDK coupling
"airflow-core/src/airflow/api/common/mark_tasks.py" = ["TID251"]
"airflow-core/src/airflow/api_fastapi/core_api/datamodels/assets.py" = ["TID251"]
"airflow-core/src/airflow/api_fastapi/core_api/datamodels/hitl.py" = ["TID251"]
"airflow-core/src/airflow/api_fastapi/core_api/datamodels/variables.py" = ["TID251"]
"airflow-core/src/airflow/api_fastapi/core_api/routes/ui/grid.py" = ["TID251"]
"airflow-core/src/airflow/api_fastapi/core_api/routes/ui/structure.py" = ["TID251"]
"airflow-core/src/airflow/api_fastapi/core_api/services/ui/connections.py" = ["TID251"]
"airflow-core/src/airflow/api_fastapi/core_api/services/ui/grid.py" = ["TID251"]
"airflow-core/src/airflow/api_fastapi/execution_api/routes/hitl.py" = ["TID251"]
"airflow-core/src/airflow/api_fastapi/execution_api/routes/task_instances.py" = ["TID251"]
"airflow-core/src/airflow/api_fastapi/logging/decorators.py" = ["TID251"]
"airflow-core/src/airflow/assets/evaluation.py" = ["TID251"]
"airflow-core/src/airflow/assets/manager.py" = ["TID251"]
"airflow-core/src/airflow/cli/commands/connection_command.py" = ["TID251"]
"airflow-core/src/airflow/cli/commands/task_command.py" = ["TID251"]
"airflow-core/src/airflow/configuration.py" = ["TID251"]
"airflow-core/src/airflow/dag_processing/collection.py" = ["TID251"]
"airflow-core/src/airflow/dag_processing/manager.py" = ["TID251"]
"airflow-core/src/airflow/dag_processing/processor.py" = ["TID251"]
"airflow-core/src/airflow/datasets/metadata.py" = ["TID251"]
"airflow-core/src/airflow/exceptions.py" = ["TID251"]
"airflow-core/src/airflow/executors/local_executor.py" = ["TID251"]
"airflow-core/src/airflow/jobs/triggerer_job_runner.py" = ["TID251"]
"airflow-core/src/airflow/lineage/hook.py" = ["TID251"]
"airflow-core/src/airflow/listeners/spec/asset.py" = ["TID251"]
"airflow-core/src/airflow/listeners/spec/taskinstance.py" = ["TID251"]
"airflow-core/src/airflow/logging/remote.py" = ["TID251"]
"airflow-core/src/airflow/models/asset.py" = ["TID251"]
"airflow-core/src/airflow/models/connection.py" = ["TID251"]
"airflow-core/src/airflow/models/dag.py" = ["TID251"]
"airflow-core/src/airflow/models/dagbag.py" = ["TID251"]
"airflow-core/src/airflow/models/dagrun.py" = ["TID251"]
"airflow-core/src/airflow/models/expandinput.py" = ["TID251"]
"airflow-core/src/airflow/models/mappedoperator.py" = ["TID251"]
"airflow-core/src/airflow/models/renderedtifields.py" = ["TID251"]
"airflow-core/src/airflow/models/serialized_dag.py" = ["TID251"]
"airflow-core/src/airflow/models/taskinstance.py" = ["TID251"]
"airflow-core/src/airflow/models/taskmap.py" = ["TID251"]
"airflow-core/src/airflow/models/taskmixin.py" = ["TID251"]
"airflow-core/src/airflow/models/variable.py" = ["TID251"]
"airflow-core/src/airflow/models/xcom.py" = ["TID251"]
"airflow-core/src/airflow/models/xcom_arg.py" = ["TID251"]
"airflow-core/src/airflow/plugins_manager.py" = ["TID251"]
"airflow-core/src/airflow/providers_manager.py" = ["TID251"]
"airflow-core/src/airflow/serialization/helpers.py" = ["TID251"]
"airflow-core/src/airflow/serialization/serialized_objects.py" = ["TID251"]
"airflow-core/src/airflow/settings.py" = ["TID251"]
"airflow-core/src/airflow/ti_deps/deps/mapped_task_upstream_dep.py" = ["TID251"]
"airflow-core/src/airflow/ti_deps/deps/prev_dagrun_dep.py" = ["TID251"]
"airflow-core/src/airflow/ti_deps/deps/trigger_rule_dep.py" = ["TID251"]
"airflow-core/src/airflow/timetables/assets.py" = ["TID251"]
"airflow-core/src/airflow/timetables/base.py" = ["TID251"]
"airflow-core/src/airflow/timetables/simple.py" = ["TID251"]
"airflow-core/src/airflow/utils/cli.py" = ["TID251"]
"airflow-core/src/airflow/utils/context.py" = ["TID251"]
"airflow-core/src/airflow/utils/dag_edges.py" = ["TID251"]
"airflow-core/src/airflow/utils/dag_parsing_context.py" = ["TID251"]
"airflow-core/src/airflow/utils/dot_renderer.py" = ["TID251"]
"airflow-core/src/airflow/utils/edgemodifier.py" = ["TID251"]
"airflow-core/src/airflow/utils/email.py" = ["TID251"]
"airflow-core/src/airflow/utils/helpers.py" = ["TID251"]
"airflow-core/src/airflow/utils/types.py" = ["TID251"]

[tool.ruff.lint.flake8-tidy-imports]
# Disallow all relative imports.
ban-relative-imports = "all"
Expand Down Expand Up @@ -856,6 +939,9 @@ banned-module-level-imports = ["numpy", "pandas", "polars"]
"sqlalchemy.ext.declarative.has_inherited_table".msg = "Use `sqlalchemy.orm.has_inherited_table`. Moved in SQLAlchemy 2.0"
"sqlalchemy.ext.declarative.synonym_for".msg = "Use `sqlalchemy.orm.synonym_for`. Moved in SQLAlchemy 2.0"
"providers".msg = "You should not import 'providers' as a Python module. Imports in providers should be done starting from 'src' or `tests' folders, for example 'from airflow.providers.airbyte' or 'from unit.airbyte' or 'from system.airbyte'"
# Task SDK import restrictions to prevent core from importing from SDK
"airflow.sdk".msg = "Airflow core should not import from Task SDK modules."
"airflow.sdk.*".msg = "Airflow core should not import from Task SDK modules."

[tool.ruff.lint.flake8-type-checking]
exempt-modules = ["typing", "typing_extensions"]
Expand Down
5 changes: 5 additions & 0 deletions task-sdk/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ namespace-packages = ["src/airflow"]

[tool.ruff.lint.per-file-ignores]

# Allow Task SDK to import from its own modules (prevents TID251 violations)
"src/**" = ["TID251"]
"tests/**" = ["TID251"]
"docs/**" = ["TID251"]

# Ignore Doc rules et al for anything outside of tests
"!src/*" = ["D", "TID253", "S101", "TRY002"]

Expand Down