Skip to content

Commit caecb8b

Browse files
ruff: move per-file-ignores into inline noqa headers (#1457)
## Why Internal coding guidelines don't allow the centralized `[tool.ruff.lint.per-file-ignores]` block in `pyproject.toml`. Exceptions must be annotated inline on the files that need them. Most of the affected files are generated, so the noqa headers have to come from the codegen templates. ## What Removes the `[tool.ruff.lint.per-file-ignores]` block from `pyproject.toml` and replaces it with inline `# ruff: noqa: <codes>` headers on the affected files. ## Where the noqas come from | File set | Codes | Source | |---|---|---| | `databricks/sdk/__init__.py` | F401 F403 F405 F811 | codegen template (`pysdkv0/templates/batch/init.py.tmpl`) | | `databricks/sdk/service/*.py` + `tests/databricks/sdk/service/*.py` | F811 F841 | codegen template (`pysdkv0/templates/packages/service.py.tmpl`) | | `databricks/sdk/errors/overrides.py` | F403 F405 | codegen template (`pysdkv0/templates/batch/error_overrides.py.tmpl`) | | `tests/generated/test_*.py` | F403 F405 | codegen template (`pysdkv0/unittestgen/{http,lro,marshall,idempotency}`) | | `databricks/sdk/core.py` | F403 F405 | hand-written (star-imports for backwards compat) | | `databricks/sdk/errors/__init__.py` | F401 F403 F405 F811 | hand-written (public re-export surface) | | `databricks/sdk/logger/__init__.py` | F401 | hand-written (re-exports `RoundTrip`) | | `databricks/sdk/runtime/__init__.py` line 127 | F401 | hand-written (intentional optional import probe) | **F401 stays uncovered on `service/*.py` on purpose**: `make fmt` runs `ruff check --fix-only` to strip the fat-import header emitted by the codegen template. Ignoring F401 there would defeat that (the autoflake-equivalent behavior the SDK relies on). ## Paired PR Template changes land in databricks-eng/universe#2008679. Regenerate via `bazel build //openapi/genkit` then `genkit update-sdk --dir .` from this checkout. Generation job runs once a day, so the two PRs are safe to merge outside of that window. ## Verification ``` $ make lint uv run ruff check databricks tests All checks passed! uv run ruff format --check databricks tests 152 files already formatted ``` This pull request and its description were written by Isaac. NO_CHANGELOG=true
1 parent bcb9b08 commit caecb8b

50 files changed

Lines changed: 134 additions & 25 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

databricks/sdk/__init__.py

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

databricks/sdk/core.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1+
# Star-import re-exports preserve backwards compatibility: config/* and
2+
# credentials_provider/* used to live in this module and are still imported
3+
# as `databricks.sdk.core.X` by callers.
4+
# ruff: noqa: F403, F405
5+
16
import re
27
from typing import BinaryIO
38
from urllib.parse import urlencode
49

510
from ._base_client import _BaseClient
611
from .config import *
7-
8-
# To preserve backwards compatibility (as these definitions were previously in this module)
912
from .credentials_provider import *
1013
from .errors import DatabricksError, _ErrorCustomizer
1114
from .oauth import retrieve_token

databricks/sdk/errors/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Re-exports the public errors API; star imports from .platform and .sdk are intentional.
2+
# ruff: noqa: F401, F403, F405, F811
3+
14
from .base import DatabricksError, ErrorDetail
25
from .customizer import _ErrorCustomizer
36
from .parser import _Parser

databricks/sdk/errors/overrides.py

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

databricks/sdk/logger/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
# ruff: noqa: F401
2+
13
from .round_trip_logger import RoundTrip

databricks/sdk/runtime/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def inner() -> Dict[str, str]:
124124
logging.debug(f"Failed to initialize globals 'sqlContext' and 'table', continuing. Cause: {e}")
125125

126126
try:
127-
from pyspark.sql.functions import udf # type: ignore
127+
from pyspark.sql.functions import udf # type: ignore # noqa: F401
128128
except ImportError as e:
129129
logging.debug(f"Failed to initialise udf global: {e}")
130130

databricks/sdk/service/agentbricks.py

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

databricks/sdk/service/apps.py

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

databricks/sdk/service/billing.py

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

databricks/sdk/service/bundle.py

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)