rusackas opened a new pull request, #41914:
URL: https://github.com/apache/superset/pull/41914
### SUMMARY
Part of the SQLAlchemy 2.0 migration battleplan: #40273
`sqlalchemy.ext.declarative.declarative_base`/`declared_attr`/`DeclarativeMeta`
are deprecated re-exports; `sqlalchemy.orm` has carried the real
implementations since 1.4. This PR:
1. Swaps the import path across all 101 occurrences in the repo (mostly
frozen historical Alembic migrations building their own scoped declarative
`Base`) to the non-deprecated `sqlalchemy.orm` path. Pure import-path change,
no behavior change — verified with `ruff check` (including import-order fixes)
and a full local test run.
2. Promotes 3 more categories in `pytest.ini`'s `filterwarnings` from a bare
warning to a regression-guarding error, now that they have zero remaining
occurrences:
- `declarative_base()` (per the fix above)
- `The Engine.execute() method is considered legacy`
- `The connection.execute() method` (distinct from the string-passing
case already enforced)
Two other candidates I checked but did **not** promote, since they're
tripped by third-party dependency code rather than anything in Superset:
- `as_declarative()` — Flask-AppBuilder's own
`flask_appbuilder/models/sqla/base_legacy.py` imports it from the deprecated
`sqlalchemy.ext.declarative` path.
- `` The `database` package is deprecated `` — `pyhive`'s own
`sqlalchemy_presto.py` does `from sqlalchemy.databases import mysql` at import
time (hits `test_presto.py`, `test_databricks*.py` at collection).
Both are left commented out in `pytest.ini`, same as before.
### TESTING INSTRUCTIONS
```bash
SQLALCHEMY_WARN_20=1 pytest tests/common tests/unit_tests
```
Ran the full suite this way locally with all 8 now-enforced categories
promoted. Only the 2 pre-existing, unrelated flaky tests fail
(`test_get_time_filter` ×6, `test_previous_calendar_quarter`) — both reproduce
identically on plain master with no env vars set at all
(date-boundary-sensitive, not related to this change).
### ADDITIONAL INFORMATION
- [ ] Has associated issue:
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]