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
{{ message }}
Repository navigation
build(pathfinder): let mypy see the package's own imports - #3622
pre-commit runs mypy from the repository root with only a config file, so mypy could not resolve cuda.pathfinder.* imports and typed every name imported from another module in the package as Any. Type errors that cross a module boundary went unreported, and cast() calls were needed to quiet "returning Any" warnings.
mypy_path = "$MYPY_CONFIG_FILE_DIR" points mypy at this directory whatever the working directory is. It works without the generated _version.py, as in CI.
With imports resolved, mypy reports three things:
Two cast() calls in header_descriptor.py are no longer needed; removed.
A real mismatch that was hidden, in the Linux loader and the Windows loader: load_with_abs_path accepted found_via: str | None = None and passed it to LoadedDL, which declares found_via: str. Every caller passes found_via (three calls in the loader, two in tests), so it is now a required str in both loaders and in the PlatformLoader protocol. No type: ignore is needed.
On Windows only: LoadedDL.abs_path is typed str | None, and it is passed to the Windows driver loader, which is declared to take str. Linux does not analyse that branch, so only the Windows pre-commit job caught it. Fixing it changes a declared type, so it is marked with a targeted type: ignore and a comment. unused-ignore is listed too, since the ignore is only needed on Windows.
Risk: load_with_abs_path is a private function. A caller outside this repository that omits found_via would now get a TypeError instead of a LoadedDL whose found_via is None.
No runtime change for any caller in this repository. 1294 passed, 6 skipped. mypy passes for both --platform linux and --platform win32.
Testing
Full cuda_pathfinder test suite at this commit: 1294 passed, 6 skipped (Linux, Python 3.14).
pre-commit clean, including mypy-pathfinder.
Not run on Windows. Windows rules are exercised by tests that simulate Windows on Linux.
PLC Local Security Evidence (Advisory)
Local advisory checks only, run over the whole stack. Not release-gate results.
Check
Status
Tool
Details
Secrets
SKIP
Pulse Secret Scanner
scanner image not available locally (registry login); the repo trufflehog pre-commit hook passed
SAST
WARN
Semgrep
1 finding, not from this stack: the existing subprocess.run call in the canary probe, now in canary_probe.py
Dependencies
WARN
pip-audit / osv-scanner
no manifest or lockfile in scope, so the local scan could not run; this stack changes no dependencies
Reviewing files that changed from the base of the PR and between aaaf45b and 4347874.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Summary
Summary by CodeRabbit
Chores
Tightened the library-loading interface: callers must now provide information about how a library was located. Type-checking configuration and diagnostics were also updated. These changes do not alter library-loading behavior or add user-facing features.
The mypy configuration now sets an import search path relative to its file. Loader methods require found_via as a string. Other source changes remove explicit casts and add type-checker suppressions.
Changes: Mypy type checks
Layer / File(s)
Summary
Configure and update type checks cuda_pathfinder/pyproject.toml, cuda_pathfinder/cuda/pathfinder/_dynamic_libs/*, cuda_pathfinder/cuda/pathfinder/_headers/header_descriptor.py, cuda_pathfinder/cuda/pathfinder/_utils/driver_info.py
The mypy configuration sets mypy_path relative to the configuration file. Linux and Windows loader signatures require found_via as a string. The driver loader call adds type-checker suppressions, and platform_include_subdirs removes explicit cast wrappers without changing its return values.
Suggested reviewers:cpcloud
Change: Other
Merge Risk: Minimal · previous review aaaf4
This PR tightens type checking for the pathfinder package and makes the found_via argument to the library loaders required. The author reports that every in-repository caller already supplies it, so no runtime impact is expected. The remaining risk is low and mostly concerns external callers that omit the argument.
Security architecture risk: Minimal · up to aaaf4
Both platform loaders now require callers to supply a discovery label. The package already supplies one on every path that uses these loaders. The public API and its library-loading behavior are unchanged, and the review found no new or increased security risk in this change.
Retained concerns
No architecture-level concerns identified.
Security review details
Security Blast Radius
inferred — Native loading still occurs inside the calling Python process. The changed signature does not add a path source, a caller, or loading privileges; the existing callers pass the same paths and labels as before.
Trust Boundaries and Controls
observed — The discovery label is not an authorization check. Linux keeps its existing label-dependent NVRTC preload rules, and Windows keeps its existing DLL directory handling and native load flags.
- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 7 remain after this review.
pre-commit runs mypy from the repository root with only a config file,
so mypy could not resolve `cuda.pathfinder.*` imports and typed every
name imported from another module in the package as `Any`. Type errors
that cross a module boundary went unreported, and `cast()` calls were
needed to quiet "returning Any" warnings.
`mypy_path = "$MYPY_CONFIG_FILE_DIR"` points mypy at this directory
whatever the working directory is. It works without the generated
`_version.py`, as in CI.
With imports resolved, mypy reports four things:
- Two `cast()` calls in `header_descriptor.py` are no longer needed;
removed.
- Two real mismatches that were hidden: `load_with_abs_path` accepts
`found_via: str | None` and passes it to `LoadedDL`, which declares
`found_via: str`. Fixing that means changing a public annotation or a
signature, so this change only marks both lines with a targeted
`type: ignore` and a comment. Nothing else needed attention.
No runtime change. 1293 passed, 6 skipped.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Rob Parolin <rparolin@nvidia.com>
With the package's imports visible, mypy on Windows reports one more
real mismatch: `LoadedDL.abs_path` is typed `str | None`, and it is
passed to the Windows driver loader, which is declared to take `str`.
Linux does not analyse that branch, so only the Windows pre-commit job
caught it.
Like the other two, it is marked with a targeted `type: ignore` and a
comment rather than fixed, because fixing it changes a declared type.
`unused-ignore` is listed too, since the ignore is only needed on
Windows.
No runtime change. mypy passes for both `--platform linux` and
`--platform win32`.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Rob Parolin <rparolin@nvidia.com>
`load_with_abs_path` took `found_via: str | None = None`, but `LoadedDL`
declares `found_via` as `str`. This change had papered over the mismatch
with two `# type: ignore[arg-type]` lines.
Every caller passes `found_via`: three calls in
`load_nvidia_dynamic_lib.py` and two in tests. So the parameter is now a
required `str` in the Linux loader, the Windows loader and the
`PlatformLoader` protocol, and both ignore lines are gone. mypy passes
for Linux and for `--platform win32`.
Risk: `load_with_abs_path` is a private function. A caller outside this
repository that omits `found_via` would now get a `TypeError` instead of
a `LoadedDL` whose `found_via` is `None`.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Rob Parolin <rparolin@nvidia.com>
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
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.
— codex on behalf of Ralf —
Description
Part 17 of 23 of a readability stack for
cuda.pathfinder(stack: #3623 → #3602 → #3603 → #3604 → #3605 → #3606 → #3607 → #3608 → #3609 → #3610 → #3611 → #3613 → #3618 → #3619 → #3620 → #3621 → #3622 → #3627 → #3628 → #3629 → #3630 → #3631 → #3632). No behavior change.pre-commit runs mypy from the repository root with only a config file, so mypy could not resolve
cuda.pathfinder.*imports and typed every name imported from another module in the package asAny. Type errors that cross a module boundary went unreported, andcast()calls were needed to quiet "returning Any" warnings.mypy_path = "$MYPY_CONFIG_FILE_DIR"points mypy at this directory whatever the working directory is. It works without the generated_version.py, as in CI.With imports resolved, mypy reports three things:
cast()calls inheader_descriptor.pyare no longer needed; removed.load_with_abs_pathacceptedfound_via: str | None = Noneand passed it toLoadedDL, which declaresfound_via: str. Every caller passesfound_via(three calls in the loader, two in tests), so it is now a requiredstrin both loaders and in thePlatformLoaderprotocol. Notype: ignoreis needed.LoadedDL.abs_pathis typedstr | None, and it is passed to the Windows driver loader, which is declared to takestr. Linux does not analyse that branch, so only the Windows pre-commit job caught it. Fixing it changes a declared type, so it is marked with a targetedtype: ignoreand a comment.unused-ignoreis listed too, since the ignore is only needed on Windows.Risk:
load_with_abs_pathis a private function. A caller outside this repository that omitsfound_viawould now get aTypeErrorinstead of aLoadedDLwhosefound_viaisNone.No runtime change for any caller in this repository. 1294 passed, 6 skipped. mypy passes for both
--platform linuxand--platform win32.Testing
cuda_pathfindertest suite at this commit: 1294 passed, 6 skipped (Linux, Python 3.14).mypy-pathfinder.PLC Local Security Evidence (Advisory)
Local advisory checks only, run over the whole stack. Not release-gate results.
subprocess.runcall in the canary probe, now incanary_probe.pyChecklist
🤖 Generated with Claude Code