You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We're incrementally shrinking the [tool.ty] rule-ignore list so ty can eventually become a required gate (see the tracking issue #15187). As discussed there, the low-hanging rules are best carved into standalone, self-contained tasks. This is the first one.
Rule:invalid-assignment — flags assigning a value whose type doesn't match the declared type of the target (attribute, variable, etc.). In this codebase every occurrence is a small, local fix — almost all are linked-list / tree next/previous attributes declared implicitly as None (or Node | None) and then reassigned a Node. The fix is an explicit annotation, e.g.:
# before: ty infers `next` as `None`, so `self.next = Node(...)` is invalidself.next=None# after:self.next: "Node | None"=None
Current occurrences (23 diagnostics across 9 files)
cellular_automata/conways_game_of_life.py — line 86
cellular_automata/one_dimensional.py — line 62
data_structures/binary_tree/non_recursive_segment_tree.py — line 63
(Line numbers are as of master today; they may drift, so re-run the check below rather than trusting them blindly.)
How to work on it
uv sync --python 3.14
# temporarily flip the rule on to see only these findings:
uv run --with ty ty check --exclude-scripts --error-on-warning \
--config-file <(sed 's/rules.invalid-assignment = "ignore"/rules.invalid-assignment = "error"/' pyproject.toml)
Or simply delete the rules.invalid-assignment = "ignore" line in pyproject.toml locally while you work, fix the reported spots, and confirm the count reaches zero.
When all 23 are fixed, remove the rules.invalid-assignment = "ignore" line from [tool.ty] in pyproject.toml in the same PR — that's what turns the rule on for good. Please keep runtime behaviour identical (annotations only; no logic changes) and make sure pytest --doctest-modules still passes for any file you touch.
Happy to review — feel free to take one file or the whole set. First-timers welcome. 🙂
Sub-task of #15187 —
good first issueWe're incrementally shrinking the
[tool.ty]rule-ignore list sotycan eventually become a required gate (see the tracking issue #15187). As discussed there, the low-hanging rules are best carved into standalone, self-contained tasks. This is the first one.Rule:
invalid-assignment— flags assigning a value whose type doesn't match the declared type of the target (attribute, variable, etc.). In this codebase every occurrence is a small, local fix — almost all are linked-list / treenext/previousattributes declared implicitly asNone(orNode | None) and then reassigned aNode. The fix is an explicit annotation, e.g.:Current occurrences (23 diagnostics across 9 files)
cellular_automata/conways_game_of_life.py— line 86cellular_automata/one_dimensional.py— line 62data_structures/binary_tree/non_recursive_segment_tree.py— line 63data_structures/heap/binomial_heap.py— lines 225, 286data_structures/linked_list/doubly_linked_list.py— lines 96, 103, 106, 145, 149, 155, 156, 175, 176data_structures/linked_list/singly_linked_list.py— lines 158, 221, 322fractals/mandelbrot.py— lines 125, 127machine_learning/automatic_differentiation.py— lines 262, 273networking_flow/minimum_cut.py— lines 85, 86(Line numbers are as of
mastertoday; they may drift, so re-run the check below rather than trusting them blindly.)How to work on it
Or simply delete the
rules.invalid-assignment = "ignore"line inpyproject.tomllocally while you work, fix the reported spots, and confirm the count reaches zero.When all 23 are fixed, remove the
rules.invalid-assignment = "ignore"line from[tool.ty]inpyproject.tomlin the same PR — that's what turns the rule on for good. Please keep runtime behaviour identical (annotations only; no logic changes) and make surepytest --doctest-modulesstill passes for any file you touch.Happy to review — feel free to take one file or the whole set. First-timers welcome. 🙂