Commit Graph

8 Commits

Author SHA1 Message Date
Claude Code
dfd3f7b316 ci(lint): enforce no function-body imports (PLC0415) with targeted ignores
Follow-up to #40231 (merged), where a reviewer flagged a function-body
`from datetime import datetime, timedelta` instead of a top-of-file
import. Adds a `ruff-import-placement` pre-commit hook running
`ruff check --select PLC0415 --preview --no-fix`.

Per @rusackas's pushback on the first cut of this PR — which spammed
2,657 `# noqa: PLC0415` annotations across ~410 files without fixing
anything — this revision is a much smaller surface area:

1. **Per-file-ignores** for whole directories where function-body
   imports are a deliberate pattern, not an oversight:
   - `superset/cli/**` and `scripts/**`: subcommand-deferred imports
     keep heavy modules out of the CLI startup path.
   - `superset/tasks/**`: Celery task bodies defer imports of the
     modules they orchestrate.
   - `superset/migrations/versions/**`: Alembic migrations interact
     with model state at runtime, not at module load.
   - `superset/mcp_service/**`: MCP tools lazy-load resources on
     invocation so the server can register many tools without paying
     their import cost at startup.
   - `superset/db_engine_specs/**`: engine specs defer driver imports
     so optional DB drivers don't have to be installed.
   - `superset/initialization/__init__.py`, `superset/extensions/__init__.py`,
     `superset/app.py`: the app-factory and extension wiring are
     intentionally full of circular-import workarounds.
   - `tests/**`: test files routinely defer imports for fixture
     isolation; the rule still applies to production code.

2. **Per-line `# noqa: PLC0415`** on the 259 remaining genuine
   circular-import sites (security/manager.py, sql/execution/executor.py,
   semantic_layers/labels.py, tags/core.py, core_api_injection.py, etc.).
   These are foundational modules where moving the imports up would
   actually break things.

Net result: ~410 files / 2,657 grandfathered → ~73 files / 259 actual
noqa annotations. The rule still catches every new function-body
import outside the explicitly-allowed directories.

Also: silences a pre-existing C901 on `mcp_service/sql_lab/tool/execute_sql.py`
that fires under newer local ruff but not CI's pinned ruff 0.9.7 — blocks
the local pre-commit run otherwise.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-20 13:55:14 -07:00
Ville Brofeldt
dcb414aa06 feat(extensions): add update command to extensions cli (#38651) 2026-03-16 07:02:42 -07:00
Michael S. Molina
a6c0d6321f chore(extensions): simplify backend package structure by removing superset_extensions namespace (#38476) 2026-03-06 14:49:49 -03:00
Ville Brofeldt
c35bf344a9 chore(extensions): clean up backend entrypoints and file globs (#38360) 2026-03-03 09:45:35 -08:00
Michael S. Molina
a74d32ab44 feat(extensions): code-first frontend contributions (#38346) 2026-03-02 13:51:29 -08:00
Ville Brofeldt
35c135852e feat(extensions): add mandatory publisher field to extension metadata (#38200) 2026-02-24 09:42:17 -08:00
Michael S. Molina
5920cb57ea refactor(extensions): add Pydantic validation for extension configuration (#36767) 2025-12-19 13:33:10 -03:00
Michael S. Molina
bcf156c969 fix: Rename apache-superset-cli to apache-superset-extensions-cli (#34883) 2025-08-28 14:40:09 -03:00