Skip to content

Fix final 80 Pyright errors — 0 errors in basic mode (Phase 4)#302

Merged
nitrobass24 merged 2 commits intodevelopfrom
chore/pyright-phase4-complex-modules
Mar 18, 2026
Merged

Fix final 80 Pyright errors — 0 errors in basic mode (Phase 4)#302
nitrobass24 merged 2 commits intodevelopfrom
chore/pyright-phase4-complex-modules

Conversation

@nitrobass24
Copy link
Owner

@nitrobass24 nitrobass24 commented Mar 18, 2026

Summary

Phase 4 and final phase of Pyright production code rollout (#249). Resolves all remaining type errors. Pyright basic mode now passes with 0 errors.

Error reduction across all phases

Phase PR Errors before Errors after
Phase 1 #292 240 240 (foundation only)
Phase 2 #295 240 149
Phase 3 #301 149 80
Phase 4 this 80 0

Next step

Remove continue-on-error: true from the python-typecheck CI job to make Pyright a required check. This should be done in a follow-up PR after this merges and CI confirms 0 errors.

Files fixed

File Errors Approach
common/config.py 18 type: ignore on intentional TypeVar/cls patterns
controller/controller.py 62 type: ignore on Config Any|None values, null guards on ModelDiff

Test plan

  • CI python-typecheck shows 0 errors
  • CI python-test passes (484 tests)
  • CI python-lint passes

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor
    • Internal type and interface cleanups to improve maintainability and reliability without changing user-facing behavior.
  • Chores
    • CI/type-check workflow tightened to enforce type checks earlier in the pipeline.

Resolves all remaining type errors in production code. Pyright basic
mode now passes with 0 errors, 0 warnings.

Files fixed:
- common/config.py (18) — type: ignore on intentional TypeVar/cls
  patterns in dynamic Config property system, cls annotation fix
- controller/controller.py (62) — type: ignore on Config Any|None
  values flowing into typed params, null guards on ModelDiff fields,
  ScannerResult|None typing on _PairContext attributes

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link

coderabbitai bot commented Mar 18, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

Converted several static utility methods in the config module to instance-like methods with TypeVar self-parameters (adding type: ignore annotations), changed Config.from_str typing to use cls: type["Config"] and call cls.from_dict(...), and added typing (ScannerResult import, nullable latest-scan fields) plus optional pair_id to the controller with many type: ignore annotations.

Changes

Cohort / File(s) Summary
Config: Converters & Checkers
src/python/common/config.py
Removed @staticmethod from multiple converters/checkers methods (null, int, bool, string_* , int_*, algorithm_allowed); added # type: ignore[...] comments to suppress TypeVar/self-parameter type checks.
Config: from_str signature & callsite
src/python/common/config.py (Config class)
Changed from_str annotation from cls: "Config" to cls: type["Config"] and replaced return Config.from_dict(...) with return cls.from_dict(...).
Controller typing tweaks
src/python/controller/controller.py
Added ScannerResult import, introduced _latest_remote_scan and _latest_local_scan on _PairContext, changed _find_pair_by_id to accept `str
CI workflow
.github/workflows/ci.yml
Removed continue-on-error: true from Python typecheck job; consolidated Pyright and dependency installation into python-typecheck job and made publish job depend on it.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐇 I nibbled at types with a curious hop,

Swapped statics for selves without a stop.
cls now steers the config's bright cart,
Scans sit snug in each pair's heart.
A rabbit's wink: ignore the linting art.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 36.36% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and accurately describes the main objective: fixing the final 80 Pyright errors to achieve 0 errors in basic mode as Phase 4 of the rollout.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/pyright-phase4-complex-modules
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/python/controller/controller.py`:
- Around line 295-297: Several call sites pass nullable config fields (e.g.,
__context.config.lftp.remote_path and __context.config.lftp.local_path) into
downstream APIs using "# type: ignore[arg-type]" which hides missing required
values until runtime; add an explicit runtime validation that fails fast.
Implement a helper (for example _validate_required_config or
validate_lftp_config) and call it before wiring/dependency construction in the
controller method that performs these calls (references:
__context.config.lftp.remote_path, __context.config.lftp.local_path and other
flagged fields), check each required attribute for None/empty and raise a clear
exception (ValueError/ConfigError) with a message naming the missing key; remove
the corresponding "# type: ignore[arg-type]" usages and apply the same
validation pattern to the other listed constructor/creator call sites so all
required config values are validated centrally before creating
scanner/lftp/validator/move objects.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 2c1729c5-68a7-46f8-b8ca-b85b63c2aa53

📥 Commits

Reviewing files that changed from the base of the PR and between be75a42 and 28e2aa7.

📒 Files selected for processing (2)
  • src/python/common/config.py
  • src/python/controller/controller.py

Comment on lines +295 to 297
remote_path=self.__context.config.lftp.remote_path, # type: ignore[arg-type]
local_path=self.__context.config.lftp.local_path, # type: ignore[arg-type]
)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Fail fast on required config values instead of suppressing nullable arguments.

Lines such as Line 295/296 and the other listed call sites pass values that are still nullable in Config (None defaults) into path/network/process APIs via # type: ignore[arg-type]. This can defer a config problem into runtime crashes in scanner, lftp, validate, and move paths.

Suggested fix (centralize runtime validation before wiring pair/process dependencies)
@@
 class Controller:
+    `@staticmethod`
+    def _require_config_str(value: str | None, field_name: str) -> str:
+        if value is None or not value.strip():
+            raise ControllerError("Missing required config value: {}".format(field_name))
+        return value
+
@@
         if not enabled_pairs:
@@
+            remote_path = self._require_config_str(
+                self.__context.config.lftp.remote_path,
+                "lftp.remote_path",
+            )
+            local_path = self._require_config_str(
+                self.__context.config.lftp.local_path,
+                "lftp.local_path",
+            )
             return [
                 self._create_pair_context(
                     pair_id=None,
                     name="Default",
-                    remote_path=self.__context.config.lftp.remote_path,  # type: ignore[arg-type]
-                    local_path=self.__context.config.lftp.local_path,  # type: ignore[arg-type]
+                    remote_path=remote_path,
+                    local_path=local_path,
                 )
             ]

Apply the same pattern to other required constructor args currently guarded only by type: ignore[arg-type].

Also applies to: 321-323, 330-333, 345-345, 347-354, 359-359, 364-364, 368-368, 407-413, 437-437, 599-599, 604-607, 621-621, 742-742, 745-750, 1119-1124, 1158-1162, 1200-1200, 1203-1208, 1261-1264, 1267-1267, 1274-1274

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/python/controller/controller.py` around lines 295 - 297, Several call
sites pass nullable config fields (e.g., __context.config.lftp.remote_path and
__context.config.lftp.local_path) into downstream APIs using "# type:
ignore[arg-type]" which hides missing required values until runtime; add an
explicit runtime validation that fails fast. Implement a helper (for example
_validate_required_config or validate_lftp_config) and call it before
wiring/dependency construction in the controller method that performs these
calls (references: __context.config.lftp.remote_path,
__context.config.lftp.local_path and other flagged fields), check each required
attribute for None/empty and raise a clear exception (ValueError/ConfigError)
with a message naming the missing key; remove the corresponding "# type:
ignore[arg-type]" usages and apply the same validation pattern to the other
listed constructor/creator call sites so all required config values are
validated centrally before creating scanner/lftp/validator/move objects.

- Install runtime deps (requirements.txt) before Pyright so bottle/tblib
  imports resolve (fixes 12 reportMissingImports errors in CI)
- Remove continue-on-error: true — Pyright is now a required check
- Add python-typecheck to publish job needs gate

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@nitrobass24 nitrobass24 merged commit 2c0aff4 into develop Mar 18, 2026
11 of 12 checks passed
@nitrobass24 nitrobass24 deleted the chore/pyright-phase4-complex-modules branch March 18, 2026 23:39
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