Repository navigation
chore(types): configure pyright and clear the error backlog - #113
Merged
Merged
Conversation
A [tool.pyright] section in pyproject.toml (basic mode, .venv env) makes the documented `pyright src/profiles` gate real: 81 errors → 0. - declare hatchling in both dev lists so the build-hook import resolves (also pre-completes #43's hatchling declaration) - execution.py: replace the dict[str, object] Popen kwargs with explicit per-platform calls (no behavior change) - inheritance.py: replace the untyped pick() closure with typed per-shape helpers; resolve_configs now produces the declared list-shaped schema fields (tests already pinned lists) - reader.py: explicit schema→model conversion (MatchCriteria + tuples) instead of relying on __post_init__ coercion - models.py: FailMode Literal defined here (bottom of the core dependency graph) and re-exported by workflow.py; launch_hook_failmode is typed FailMode - columns chain typed dict[str, ColumnConfiguration] across classifier/scanner/scan route; the _iter_columns workaround is deleted while its non-dict contract is kept via isinstance (pinned by test_non_dict_columns_ignored) - real bugs found by the gate: app.py run_headless accessed cfg.directory (a nonexistent field) and crashed whenever machine configurations existed — now iterates cfg.scan; handoff.py could hit an unbound `detail` when reading the HTTPError body failed; matcher.py returned tuple|bool against a bool contract - tkinter fallbacks (interactions, message_dialog) restructured into import/display try blocks (no possibly-unbound tk) - targeted pyright: ignore only where third-party stubs are absent (pyobjc, ctypes.windll, os.startfile, build-hook base union) and on the legacy HookSpec/WorkflowStep engine mismatch pending #39 - pylint pragma prose moved off pragma lines (7 spurious W0012)
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.
Fixes #69 — the documented
pyright src/profilesgate now works: 81 errors → 0, on top of the Tkinter removal (#112, which already cleared the ~34 gui/ errors).Configuration
[tool.pyright]inpyproject.toml(basic mode,.venvenv,pythonVersion 3.11,extraPaths: ["src"]). Basic mode on purpose: the gate is regression insurance, not strict-mode adoption.hatchling>=1.26declared in both dev lists soweb/build_hook.py's import resolves — also pre-completes the hatchling declaration deptry: declare hatchling and direct transitive imports (PIL, objc, WebKit) and actually run deptry #43 calls for.Real type fixes (no suppression)
execution.py×28 (Popen kwargs fromdict[str, object])Popencalls — same kwargs, no dictinheritance.py×13 (untypedpick()closure)pick_str_list,pick_row_colors,pick_match,pick_scan);resolve_configsnow produces the declared list-shaped schema fields — the tests already pinned lists, pydantic was silently coercing the tuplesreader.py×7 (schema→model drift)MatchCriteria, tuples) at the boundary instead of relying on__post_init__coercionactions.py×2 (failmode: str)FailModeLiteral moved tomodels.py(bottom of the core graph), re-exported byworkflow.py;AppConfig.launch_hook_failmodetypedobject-typed dicts)dict[str, ColumnConfiguration]across classifier/scanner/scan route;_iter_columnsworkaround deleted, its pinned non-dict contract kept viaisinstance(test_non_dict_columns_ignoreduntouched)tkpossibly unbound)matcher.py,schema.py,diagnostics.py,handoff.py,__init__.py,scanner.py,server/app.py,qrcode/zxingcppcastin the before-validator, narrowedsys.excepthookparams, explicit submodule imports, honest return annotationsReal bugs the gate surfaced (fixed)
app.pyheadless scan path crashed whenever machine configurations existed — it readcfg.directory, a fieldMachineConfigurationdoesn't have (AttributeErrorat runtime; the tests only exercised the empty-configurations path). Now iteratescfg.scanas documented ("scan all configured directories").handoff.pycould hit an unbounddetail(NameError) when reading the HTTPError body raised inside thesuppressblock.matcher.pyreturnedtuple | boolagainst a-> boolcontract; nowbool(m.path) and ....Suppression ledger (9 lines, all commented)
execution.py×4 — legacy HookSpec engine readswhenoffWorkflowStepobjects; the engine's fate is Dead code sweep (Python): legacy phase-based hook engine, tests-only helpers, unused --no-config-propose flag #39's call, suppressed with a pointer instead of redesigning it here.file_utils.py×3os.startfile,shortcut.pyctypes.windll,launcher.pyobjc.selector— Windows-only / stub-less third-party attributes, all runtime-guarded.build_hook.py×1 — theobjectruntime fallback unions the base-class binding; every env that loads the hook has hatchling.Also
schema.py,interactions.py) moved the prose off the pragma lines — the 7 spuriousunknown-option-value(W0012) warnings are gone.Verification
pyright src/profiles: 0 errors, 0 warningsruff format --check+ruff check: cleanpylint src/profiles: 9.88/10 (gate 8.0)pytest: 1490 passed, 1 skipped (pre-existing macOS Finder probe), coverage 88.61% (gate 85%)import profiles.appsmoke: clean; pre-commit hooks greenFollow-up
#48's CI quality gate can now include
uv run pyright src/profiles— that wiring is left to #48.