Skip to content

pre-commit: Add ruff rules for unsafe naive datetimes - #1060

Open
cclauss wants to merge 1 commit into
celery:mainfrom
cclauss:ruff-rules-DTZ
Open

pre-commit: Add ruff rules for unsafe naive datetimes#1060
cclauss wants to merge 1 commit into
celery:mainfrom
cclauss:ruff-rules-DTZ

Conversation

@cclauss

@cclauss cclauss commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Fixes: #1059

Lint rules to ban the usage of unsafe naive datetimes.

% ruff check --select=DTZ --statistics

7	DTZ001	call-datetime-without-tzinfo
7	DTZ005	call-datetime-now-without-tzinfo
5	DTZ003	call-datetime-utcnow
Found 19 errors.

Related to:

@codecov

codecov Bot commented Jul 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 87.90%. Comparing base (6594458) to head (8a858f7).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
django_celery_beat/schedulers.py 66.66% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1060   +/-   ##
=======================================
  Coverage   87.90%   87.90%           
=======================================
  Files          32       32           
  Lines        1025     1025           
  Branches       84       84           
=======================================
  Hits          901      901           
  Misses        106      106           
  Partials       18       18           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread django_celery_beat/schedulers.py Outdated
@cclauss
cclauss requested a review from alirafiei75 July 3, 2026 05:43
@cclauss
cclauss requested review from Nusnus and auvipy July 3, 2026 14:12
def schedule(self):
initial = update = False
current_time = datetime.datetime.now()
current_time = aware_now()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this change and the one above demands unit tests for verification. @alirafiei75 what do you think?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think that is critical because both of the changes do not make any logical difference and there are already unit tests on the function. but it wouldn't hurt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DatabaseScheduler.schedule().current_time is a naive datetime

3 participants