jasontd92 opened a new pull request, #45697:
URL: https://github.com/apache/superset/pull/45697

   ### SUMMARY
   
   `datetime.utcnow()` is deprecated since Python 3.12 ("Use `datetime.now()` 
with `UTC` instead": 
https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow). 
#41502 replaced the production call sites under `superset/` with naive-UTC 
equivalents. Five uses remain:
   
   - `superset/models/core.py`: `Log.dttm` and `FavStar.dttm` column defaults 
(`default=datetime.utcnow`, a callable reference, so the earlier sweep for 
`utcnow()` calls did not catch them).
   - `superset/models/sql_lab.py`: `Query.changed_on` `default` and `onupdate`.
   - `superset/commands/report/execution_claim.py`: two calls added later in 
#44336.
   
   These now use the existing `superset.utils.dates.naive_utcnow()` helper, 
which returns `datetime.now(timezone.utc).replace(tzinfo=None)`. Values stay 
naive UTC, as before, so stored timestamps and comparisons are unchanged. In 
`execution_claim.py`, the one inline 
`datetime.now(timezone.utc).replace(tzinfo=None)` in `cancel_disabled_retry` 
also uses the helper, so the file is consistent. `datetime` is no longer used 
in `models/core.py`, so its import is removed.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   N/A
   
   ### TESTING INSTRUCTIONS
   
   No behaviour change. Run on Python 3.11 with `requirements/development.txt` 
installed, first on `master` for a baseline and then on this branch:
   
   ```
   TZ=UTC pytest -n 6 tests/unit_tests/commands/report 
tests/unit_tests/commands/logs tests/unit_tests/models 
tests/unit_tests/sql_lab_test.py tests/unit_tests/dao
   ruff check <changed files> && ruff format --check <changed files>
   mypy --check-untyped-defs <changed files>
   ```
   
   - pytest: 2503 passed, 26 skipped, both before and after.
   - ruff and ruff format: clean.
   - mypy: same error set in the changed files before and after.
   
   `grep -rn "utcnow" superset --include='*.py' | grep -v migrations` now only 
matches `naive_utcnow` and unrelated private helpers.
   
   ### ADDITIONAL INFORMATION
   
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   
   Found with [unstale](https://github.com/vuca-dev/unstale), a tool I'm 
building so nobody has to read every changelog to catch changes like this one. 
Prepared with AI assistance (Claude Code) and verified as described above.
   


-- 
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]

Reply via email to