Skip to content

Commit b2beaae

Browse files
committed
Enable ruff DTZ rules and all datetime calls now use an explicit timezone
1 parent cdab429 commit b2beaae

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

cmd2/cmd2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2562,7 +2562,7 @@ def onecmd_plus_hooks(
25622562

25632563
redir_saved_state = self._redirect_output(statement)
25642564

2565-
timestart = datetime.datetime.now()
2565+
timestart = datetime.datetime.now(tz=datetime.timezone.utc)
25662566

25672567
# precommand hooks
25682568
precmd_data = plugin.PrecommandData(statement)
@@ -2588,7 +2588,7 @@ def onecmd_plus_hooks(
25882588
stop = self.postcmd(stop, statement)
25892589

25902590
if self.timing:
2591-
self.pfeedback(f'Elapsed: {datetime.datetime.now() - timestart}')
2591+
self.pfeedback(f'Elapsed: {datetime.datetime.now(tz=datetime.timezone.utc) - timestart}')
25922592
finally:
25932593
# Get sigint protection while we restore stuff
25942594
with self.sigint_protection:

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,9 @@ select = [
169169
# "CPY", # flake8-copyright (warn about missing copyright notice at top of file - currently in preview)
170170
# "D", # pydocstyle (warn about things like missing docstrings)
171171
# "DOC", # pydoclint (docstring warnings - currently in preview)
172-
"DJ", # flake8-django (Django-specific warnings)
173-
# "DTZ", # flake8-datetimez (warn about datetime calls where no timezone is specified)
174-
"E", # pycodestyle errors (warn about major stylistic issues like mixing spaces and tabs)
172+
"DJ", # flake8-django (Django-specific warnings)
173+
"DTZ", # flake8-datetimez (warn about datetime calls where no timezone is specified)
174+
"E", # pycodestyle errors (warn about major stylistic issues like mixing spaces and tabs)
175175
# "EM", # flake8-errmsg (warn about exceptions that use string literals that aren't assigned to a variable first)
176176
# "ERA", # eradicate (warn about commented-out code)
177177
# "EXE", # flake8-executable (warn about files with a shebang present that aren't executable or vice versa)

0 commit comments

Comments
 (0)