Skip to content

nixoslogo: fix all type errors and most lint findings - #77

Merged
djacu merged 43 commits into
mainfrom
djacu/lint-fixes
Oct 11, 2026
Merged

djacu merged 43 commits into
mainfrom
djacu/lint-fixes

Conversation

@djacu

@djacu djacu commented Oct 11, 2026 •

Copy link
Copy Markdown
Member

Clears every basedpyright error in nixoslogo and most of the warnings.

basedpyright   222 errors, 1527 warnings  ->  0 errors, 288 warnings
ruff            28 errors                 ->  1 error

make_svg_elements now returns a flat list[svg.Element]. svg joins nested sequences with a space, so flattening removes inter element whitespace from 72 of the 96 artifacts. The XML is structurally identical: compare-artifacts reports all 96 unchanged, and every element keeps the same ancestor path. The affected outputHash values are updated in the same commit.

requires-python moves to 3.12 for typing.override.

Assisted-by: Claude Code (Claude Opus 5)

djacu added 30 commits October 10, 2026 12:37
Rework so we don't need the conditional guard which allows type
inference to work.
The abstract make_svg_elements had no return annotation and inferred
None, so make_svg could not concatenate it with make_svg_background.
Implementations returned tuples nested up to three deep. Three in
dimensioned.py were annotated svg.SVG but returned concatenated tuples.

Add flatten_svg_elements and a recursive SvgElements alias to core. The
abstract and all nineteen implementations now return list[svg.Element].

svg-py declares elements as list[Element] | None. Passing tuples was an
error at fifteen elements= call sites; twelve are fixed here.

In dimensioned.py the concatenation operands become helper arguments.
The + operator would raise TypeError once super().make_svg_elements()
returned a list and the other operand was a tuple.

svg-py joins nested sequences with a space. Flattening drops that
whitespace from 72 of the 96 artifacts. Element ancestor paths are
unchanged and compare-artifacts reports all 96 unchanged. Update the
affected outputHash values.

Assisted-by: Claude Code (Claude Opus 5)
The package ships inline annotations but no PEP 561 marker, so type
checkers treated its own modules as untyped libraries. Clears 37
reportMissingTypeStubs warnings.
Lambda is defined in nixoslogo.logomark. clearspace.py imported it from
nixoslogo.logo, which only imports it for its own use. The py.typed
marker makes type checkers enforce export discipline, so this was
reported as a private import.
logo is instantiated as self.logo(clear_space=...) and every caller
passes a class, not an instance.
tuple[Color] is a one-element tuple. LogomarkColors members hold one,
two, three and six colors, so the parameter annotation was wrong for
most of them. Widen to tuple[Color, ...] in Logomark and NixosLogo.
NixosLogo stored logotype_cap_height, loader and logotype_transform as
optional attributes and filled them in from _init_cap_height,
_init_logotype and _init_layout, so every later use was an optional
access. Replace the mutating hooks with _default_cap_height and
_default_transform and assign each attribute once. LogoScale overrides
_default_cap_height instead of _init_cap_height.
reference is a Fraction denominator when fractional is true and a
plain divisor otherwise, so it was unannotated and inferred as int
from its default while five call sites passed a float cap height.
Point, Points, Vector and Matrix are never subclassed, but twelve
methods were annotated -> Self while returning the concrete class.
Point.__sub__ returns a Vector for a Point and a Point for a Vector, so
it needs overloads; distance has always relied on that and was reported
as calling length on a Point.

Vector.__matmul__ and Matrix.__matmul__ return a list, _modulus_squared
returns a float, and transpose built a Matrix of tuples rather than
Vectors.

svg._types.Number is Decimal | float | int and describes svg attribute
values, not arithmetic operands: Decimal * float is a TypeError. Use
float for the thirteen annotations that take part in arithmetic.

make_diagonal_line returns Points, not list[Number], and the dimension
offset is a float because dimension_spacings divides by a length.

Assisted-by: Claude Code (Claude Opus 5)
Point, Points, Vector and Matrix subclassed a bare Sequence, so
everything read out of them was Unknown.
SVG's stroke-dasharray is a list of dash lengths; a bare number is
shorthand. LineGroup declared it int, so every svg element built from
an annotation config was an argument type error.
jsonpickle.encode is unannotated upstream and infers str | None; cast
it like the other untyped boundaries.

tuple[int] is a one-element tuple, so both spacings annotations
rejected their own five-element defaults.

Glyph declared character as str | None, but character=None raises
TypeError from the font lookup and no caller passes it. Removing the
option also fixes the filename join. _map_characters needed its own
annotation so dict.get would not widen the result back to str | None.

Assisted-by: Claude Code (Claude Opus 5)
@github-actions

Copy link
Copy Markdown

Artifact comparison

0 modified · 0 added · 0 deleted · 96 unchanged

Download report — HTML file; open in a browser.

Compared
  • Base: 4faef6a7eb6094d0543d4047bd19551b3a2edf48 (current main tip when this ran)
  • After: c7bde6967c54f9887205367b88c354c4d94f0e39 (merge commit; falls back to PR head if unmergeable)

@djacu
djacu merged commit 24f982b into main Oct 11, 2026
6 checks passed
@djacu
djacu deleted the djacu/lint-fixes branch October 11, 2026 14:19
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.

1 participant