fix: correct type() misuse, unused imports, exit(), and timezone-naiv…#2139
Open
Acuspeedster wants to merge 1 commit into
Open
Conversation
…e datetime - jinja/tags.py: replace type(x is str) with isinstance(x, str). type(kwargs['format'] is str) always evaluated to <class 'bool'> (truthy), making the else branch (default format fallback) unreachable dead code and silently passing non-string values to strftime(). - catalog_merger.py: remove 7 list_utils imports that were never used (as_dict, as_filtered_list, as_list, delete_item_from_list, deep_set, get_item_from_list, none_if_empty). Only set_or_pop is actually called. - cli.py: replace exit() with sys.exit(). The built-in exit() is intended for interactive interpreter use; sys.exit() is correct for application code. Add missing 'import sys'. - cache.py: pass tz=datetime.timezone.utc to both fromtimestamp() and now() so the timedelta calculation is timezone-aware and immune to DST transitions. Signed-off-by: Acuspeedster <arnavrajsingh@gmail.com>
Contributor
Author
butler54
requested changes
Mar 24, 2026
butler54
left a comment
Collaborator
There was a problem hiding this comment.
Please fix the merge conflicts and re-request review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix: correct type() misuse, unused imports, exit(), and timezone-naive
datetime
jinja/tags.py: replace
type(x is str)withisinstance(x, str).type(kwargs['format'] is str)always evaluated to<class 'bool'>(truthy), making the
elsebranch (default format fallback)unreachable dead code and silently passing non-string values to
strftime().catalog_merger.py: remove 7 unused
list_utilsimports that werenever used (
as_dict,as_filtered_list,as_list,delete_item_from_list,deep_set,get_item_from_list,none_if_empty). Onlyset_or_popis actually referenced.cli.py: replace
exit()withsys.exit(). The built-inexit()isintended for interactive interpreter use;
sys.exit()is correctfor application code. Added missing
import sys.cache.py: pass
tz=datetime.timezone.utcto bothfromtimestamp()and
now()so the timedelta calculation is timezone-aware andimmune to DST transitions.
Types of changes
functionality to change)
develop->main)Quality assurance (all should be covered).
How To Test
If using act (https://github.com/nektos/act), fill in below:
Summary
Four independent bug fixes identified during static analysis. These
changes correct logic errors, remove dead imports, ensure correct
program exit behavior, and make datetime arithmetic timezone-safe. No
functional changes beyond fixing the identified bugs.
Files changed
trestle/core/jinja/tags.pytype(x is str)→isinstance(x, str)trestle/core/catalog/catalog_merger.pylist_utilsimportstrestle/cli.pyexit()withsys.exit()trestle/core/remote/cache.pydatetime.timezone.utcfor datetime arithmeticTesting
ruff checkclean for modified filesKey links:
coverage
Before you merge
out, if required.