chore(typecheck): include top-level tools#612
Conversation
WalkthroughChangesTooling typing and data handling
Estimated code review effort: 3 (Moderate) | ~25 minutes Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
c7fbb20 to
eceb66e
Compare
75ff152 to
1e74819
Compare
eceb66e to
46af38a
Compare
1e74819 to
670ffdd
Compare
46af38a to
0c08cb9
Compare
9c96037 to
8d55e69
Compare
62ba809 to
8d3f148
Compare
8d55e69 to
97c3d20
Compare
9af5f17 to
cf5ea01
Compare
97c3d20 to
b0fc400
Compare
cf5ea01 to
3f2bc65
Compare
b0fc400 to
3ca326f
Compare
3f2bc65 to
967deb4
Compare
3ca326f to
ab75d47
Compare
967deb4 to
a9286fc
Compare
ae3cfb7 to
f99a9d9
Compare
0e72757 to
3d5719d
Compare
f99a9d9 to
148fa85
Compare
756d95c to
3d5719d
Compare
3d5719d to
31ff9f5
Compare
a5f72a0 to
82d7677
Compare
The base branch was changed.
Signed-off-by: Aaron Gonzales <aagonzales@nvidia.com>
82d7677 to
b5549c2
Compare
|
|
||
|
|
||
| def _extract_source(raw: dict) -> str: | ||
| def _extract_source(raw: dict[str, Any]) -> str: |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Greptile SummaryThis PR enables type checking for the
Confidence Score: 5/5All changes are purely additive type annotations and equivalent refactors of existing logic; no runtime behavior is altered. The diff is confined to type-level changes: adding annotations, introducing typed helper wrappers, and rewriting No files require special attention. Important Files Changed
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
tools/diff-lockfile.py (1)
39-39: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse a read-only typed mapping instead of
Any.
_extract_sourceonly readsraw, soMapping[str, object]models the contract more accurately, avoids uncheckedAnypropagation, and accepts the concrete TOML mapping passed by callers.Suggested typing adjustment
+from collections.abc import Mapping -from typing import Annotated, Any, Optional +from typing import Annotated, Optional-def _extract_source(raw: dict[str, Any]) -> str: +def _extract_source(raw: Mapping[str, object]) -> str:As per coding guidelines: use collection ABCs for function arguments and avoid
Anywhenobjectis suitable.Also applies to: 119-119
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 678d2ec6-1796-43a4-a17b-7bbc45f64f3b
📒 Files selected for processing (4)
pyproject.tomltools/diff-lockfile.pytools/hf_network_guard_proxy.pytools/patch_dependabot.py
💤 Files with no reviewable changes (1)
- pyproject.toml
📜 Review details
⏰ Context from checks skipped due to timeout. (1)
- GitHub Check: Greptile Review
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{md,markdown,py}
📄 CodeRabbit inference engine (.cursor/rules/agent-markdown-style.mdc)
**/*.{md,markdown,py}: Avoid decorative bold (**text**) in list items, body text, and docstrings; use structural cues (headers, list markers, colons, backticks) for emphasis instead
Use backticks for code identifiers, paths, and CLI commands in markdown and docstrings
Files:
tools/diff-lockfile.pytools/hf_network_guard_proxy.pytools/patch_dependabot.py
**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
**/*.py: Place durable implementation guidance in function and class docstrings for public contracts and source comments for local invariants
Target Python 3.11–3.13 with modern syntax (X | Y,list[str],Self). Python 3.14+ is not supported
**/*.py: Use American English spelling in Python code, documentation, and messages.
UseField(description=...)for every Pydantic model field.
Use assignment-styleField()by default; useAnnotatedonly for additional metadata such as validators, constrained aliases, or discriminated unions.
Use@dataclass(frozen=True)for immutable value objects and validators; use mutable dataclasses only for builders, accumulators, and pipeline state.
Usefield(default_factory=list)instead of mutable list defaults.
UseStrEnumfor string-valued configuration or serialization enums and plainEnumfor internal constants.
Obtain loggers withobservability.get_logger(__name__); do not calllogging.getLogger()orstructlog.get_logger()directly.
Use.runtime,.user, and.systemcategory loggers appropriately.
Do not useprint()for operational library output; use the approved logger,click.echo(), orsys.stdout.write()where appropriate.
Useextra={}for machine-queryable logging data and f-strings only for human-readable context.
Raise errors from the custom Safe Synthesizer error hierarchy, using the documented dual inheritance for user and internal errors.
Keep shared package code compatible with Python 3.11; do not use Python 3.12-only syntax such as PEP 695 type statements or bracketed generic parameters.
PreferX | Y, built-in collection generics, andSelfoverOptional,Union, and legacy typing collections.
Use collection ABCs for function arguments and concrete collection types for return values.
UseProtocolfor structural subtyping and avoidAnywhenobject, generics, or protocols are suitable.
UseTYPE_CHECKINGguards for heavy imports such as pandas, torch, and transformers.
...
Files:
tools/diff-lockfile.pytools/hf_network_guard_proxy.pytools/patch_dependabot.py
**/*
📄 CodeRabbit inference engine (STYLE_GUIDE.md)
**/*: Every source file requires the SPDX copyright and license header appropriate to its file format.
End files with a newline, remove trailing whitespace, use one space between sentences, and keep code, comments, and docstrings within 120 characters.
**/*: All merged commits must use Conventional Commits format:<type>(<scope>): <description>or<type>: <description>, with a lowercase valid type and a description no longer than 100 characters.
All contributions require a DCOSigned-off-bytrailer and a cryptographic commit signature.
Before submitting a pull request, run formatting, checks, and tests usingmise run format,mise run check, andmise run test.
Branches other thanmainmust use lowercase author-prefixed names in one of the documented forms, optionally including an issue ID and category.
Release tags must use avprefix and PEP 440 stable or release-candidate versions, such asv1.0.0orv0.1.0rc0; alpha versions and dashed-rcsuffixes are not used.
Do not move a published release tag; create and validate a new release candidate when code changes.
Usemise run <task>for project tasks; the Makefile only bootstraps mise and provides deprecated compatibility messages.
Files:
tools/diff-lockfile.pytools/hf_network_guard_proxy.pytools/patch_dependabot.py
⚙️ CodeRabbit configuration file
**/*: Review as a senior maintainer for NeMo Safe Synthesizer. Prioritize issues that can change behavior, break user workflows, weaken privacy guarantees, hide failures, make tests unreliable, or create maintenance risk. Avoid generic style commentary unless it points to a concrete project convention that automated tools will not catch.
Comment only when the finding is actionable and tied to changed code. For each finding, state the impact, the condition that triggers it, and the smallest practical fix. Prefer one precise comment over broad advice. Do not ask for refactors outside the PR scope unless the changed code creates the problem.
Review type guidance: - Potential issue: use for correctness bugs, data loss, privacy leaks,
security risks, broken public APIs, invalid config behavior, missing
validation, hidden failures, nondeterministic tests, or CI breakage.
- Refactor suggestion: use for local maintainability problems introduced
by the diff when they have clear future cost, such as duplicated setup,
unclear boundaries, over-mocking, avoidable complexity, or opaque test
helpers.- Nitpick: avoid in chill mode. Do not emit formatting, import-order,
wording, or style-only comments unless automated tools cannot catch the
issue and it affects maintainability.Severity guidance: - Critical: security/privacy leaks, data loss, training/test/holdout
contamination, or broken release/package/core pipeline execution.
- Major: incorrect generation/training/evaluation behavior, broken
CLI/SDK public API, invalid config defaults or validators, or GPU/vLLM
cleanup and process-isolation bugs likely to fail CI or production
runs.- Minor: localized bugs, missing focused tests for changed behavior, or
bad test patterns that weaken regression coverage.- Trivial: small cleanup with no behavior impact. Usually suppress in
chill mode.- Info: context only. Avoid unless it helps reviewers understand risk.
Safe-Synthesizer-specific review focus: - Data ...
Files:
tools/diff-lockfile.pytools/hf_network_guard_proxy.pytools/patch_dependabot.py
**/*.{py,sh,yaml,yml,md}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
All source files with
.py,.sh,.yaml,.yml, or.mdextensions must include SPDX copyright headers, except files listed in.copyrightignore.
Files:
tools/diff-lockfile.pytools/hf_network_guard_proxy.pytools/patch_dependabot.py
tools/**
⚙️ CodeRabbit configuration file
Review tools as developer and CI infrastructure. Check that scripts use uv or Makefile wrappers instead of ad hoc python/pip commands, preserve read-only behavior for check targets, fail with clear messages, avoid hidden network or filesystem side effects, and stay consistent with STYLE_GUIDE.md and CONTRIBUTING.md. Tooling may use print() when it is a standalone script or intentional CLI output.
Files:
tools/diff-lockfile.pytools/hf_network_guard_proxy.pytools/patch_dependabot.py
🔇 Additional comments (15)
tools/patch_dependabot.py (8)
10-10: LGTM!
34-58: LGTM!
130-195: LGTM!
236-256: LGTM!
274-274: LGTM!
291-302: LGTM!
322-324: LGTM!Also applies to: 336-336
366-382: LGTM!tools/hf_network_guard_proxy.py (5)
11-11: LGTM!
78-78: LGTM!
94-94: LGTM!
175-175: LGTM!
206-207: LGTM!tools/diff-lockfile.py (2)
121-123: LGTM!
126-129: LGTM!
| case dict(): | ||
| return "" |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
printf '%s\n' 'Lockfile source shapes:'
rg -n '^\s*source\s*=\s*\{' --glob 'uv.lock' --glob '**/uv.lock' || true
printf '%s\n' 'Parser tests and usages:'
rg -n '_extract_source|parse_packages' --glob '*.py' || trueRepository: NVIDIA-NeMo/Safe-Synthesizer
Length of output: 190
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
printf '%s\n' '--- tools/diff-lockfile.py outline ---'
ast-grep outline tools/diff-lockfile.py --view expanded || true
printf '%s\n' '--- relevant lines around _extract_source and parse_packages ---'
sed -n '1,260p' tools/diff-lockfile.py | cat -n
printf '%s\n' '--- lockfiles containing source tables ---'
rg -n '^\s*source\s*=\s*\{' --glob 'uv.lock' --glob '**/uv.lock' . || true
printf '%s\n' '--- usages/tests for duplicate keys or source extraction ---'
rg -n 'parse_packages|_extract_source|name@source|source\]' tools test . || trueRepository: NVIDIA-NeMo/Safe-Synthesizer
Length of output: 36307
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
python3 - <<'PY'
from collections import defaultdict
from pathlib import Path
import tomllib
lock = tomllib.loads(Path("uv.lock").read_text())
packages = lock.get("package", [])
by_name = defaultdict(list)
source_shapes = defaultdict(int)
for pkg in packages:
name = pkg.get("name")
source = pkg.get("source")
if isinstance(source, dict):
source_shapes[tuple(sorted(source.keys()))] += 1
by_name[name].append((pkg.get("version"), source))
print("unique source key sets:")
for keys, count in sorted(source_shapes.items(), key=lambda kv: (len(kv[0]), kv[0])):
print(f"{count:4d} {keys}")
print("\nduplicate package names with distinct source reprs:")
for name, items in sorted(by_name.items()):
if len(items) > 1:
uniq = []
seen = set()
for version, source in items:
rep = (version, repr(source))
if rep not in seen:
seen.add(rep)
uniq.append((version, source))
if len(uniq) > 1:
print(f"\n{name}:")
for version, source in uniq:
print(f" version={version!r} source={source!r}")
PYRepository: NVIDIA-NeMo/Safe-Synthesizer
Length of output: 2601
Keep package variants distinct in parse_packages. name@source still collapses multiple [[package]] entries that share the same name and source, so later versions overwrite earlier ones and the lockfile diff can miss dependency changes. Include version in the key or store all variants per package name/source.
Source: Path instructions
Summary
Test plan
Related issue: #614
Summary by CodeRabbit
Bug Fixes
Maintenance