fix: avoid mutable default arguments and use identity check for type comparison - #282
Open
harshadkhetpal wants to merge 1 commit into
Open
Conversation
…comparison Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
harshadkhetpal
requested review from
Akshat0694,
arunim2405 and
refeed
as code owners
August 18, 2026 10:08
|
❌ The last analysis has failed. |
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.
Summary
Three small correctness fixes flagged by ruff (B006 / E721):
src/tirith/core/core.py—start_policy_evaluation(var_paths: List[str] = [], inline_vars: List[str] = [])andstart_policy_evaluation_from_dict(var_dict: Dict = {})used mutable default arguments. Python evaluates defaults once at definition time, so the same list/dict object is shared across every call — a latent state-leak footgun, especially forvar_dict, which is passed intoget_policy_with_vars_replaced(). Changed to theOptional[...] = Nonesentinel pattern with normalization at the top of each function; behavior is unchanged for all existing callers.src/tirith/core/evaluators/regex_match.py—type(evaluator_data) == strcompares type objects with==; identity (is str) is the intended semantics and is what newer linters (ruff E721) require.Testing
python -m py_compilepasses on both files andruff check --select B006,E721is clean after the change. No functional change for existing callers.🤖 Generated with Claude Code