Skip to content

Commit 12bfaff

Browse files
feat(lint): Upgrade ty (#543)
* squash Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> * fix(lint): suppress new ty 0.0.56 error categories in CI The ty upgrade from 0.0.17 to 0.0.56 catches additional pre-existing type violations. Add these new error categories to the CI ignore list with counts, matching the existing pattern for incremental cleanup. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> * fix(lint): add --exit-zero-on-warning for ty 0.0.56 ty 0.0.56 exits non-zero on warnings (unsupported-base, unused-type-ignore-comment, redundant-cast). Add --exit-zero-on-warning so only errors fail CI. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> * fix(lint): resolve all new ty 0.0.56 errors at source Instead of adding blanket suppressions for new error categories, fix each violation individually: - Fix with_logging decorator in anonymizer/data-designer to preserve class types through TypeVar (invalid-type-form) - Fix StudioService.dependencies to use ClassVar (invalid-attribute-override) - Add inline ty: ignore comments for false positives and intentional test misuse (invalid-paramspec, call-non-callable, unknown-argument, missing-argument, empty-body, too-many-positional-arguments, invalid-yield, unresolved-import, invalid-type-form) No new blanket suppressions added to lint-python-types.sh. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> * fix(lint): consolidate duplicate type ignore comments Replace `# type: ignore[rule] # ty: ignore[rule]` with blanket `# type: ignore` on lines that need both mypy and ty suppression. Blanket `# type: ignore` is respected by both checkers, eliminating the need for separate directives. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> * Revert "fix(lint): consolidate duplicate type ignore comments" This reverts commit cd7b6f6. Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> * fix(lint): use ty: ignore instead of type: ignore This repo uses ty, not mypy. Replace redundant dual comments (# type: ignore[rule] # ty: ignore[rule]) with just # ty: ignore[rule] on the 14 lines we touched for the ty upgrade. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> * chore: sync vendored SDK and CLI after ty ignore cleanup Run make vendor and make update-cli to sync the evaluator SDK vendored files with the ty: ignore comment changes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> --------- Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 9aa4f5c commit 12bfaff

28 files changed

Lines changed: 532 additions & 57 deletions

File tree

packages/nemo_evaluator_sdk/src/nemo_evaluator_sdk/resilience/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ async def run_with_resilience(
6969
endpoint_key: str,
7070
operation: Callable[_P, Awaitable[_T]],
7171
*args: _P.args,
72-
max_attempts: int,
72+
max_attempts: int, # ty: ignore[invalid-paramspec]
7373
deadline_at: float | None = None,
7474
**kwargs: _P.kwargs,
7575
) -> _T:

packages/nemo_evaluator_sdk/src/nemo_evaluator_sdk/resilience/scheduler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ async def run_with_resilience(
105105
endpoint_key: str,
106106
operation: Callable[_P, Awaitable[_T]],
107107
*args: _P.args,
108-
max_attempts: int,
108+
max_attempts: int, # ty: ignore[invalid-paramspec]
109109
deadline_at: float | None,
110110
**kwargs: _P.kwargs,
111111
) -> _T:
@@ -202,7 +202,7 @@ async def _run_once(
202202
endpoint_key: str,
203203
operation: Callable[_P, Awaitable[_T]],
204204
*args: _P.args,
205-
attempt: int,
205+
attempt: int, # ty: ignore[invalid-paramspec]
206206
**kwargs: _P.kwargs,
207207
) -> _T:
208208
controller = await self._get_controller(endpoint_key)

packages/nemo_evaluator_sdk/tests/metrics/test_llm_judge.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ async def test_rubric_compute_scores_emits_numeric_score_and_label(self, mocker:
522522

523523
def test_unique_scores_allows_empty_scores_for_constructed_model(self):
524524
metric = LLMJudgeMetric.model_construct(model=_make_model(), scores=[], _fields_set={"model", "scores"})
525-
assert metric.unique_scores() is metric # type: ignore[call-non-callable] # Pydantic model_validator descriptor
525+
assert metric.unique_scores() is metric # ty: ignore[call-non-callable] # Pydantic model_validator descriptor
526526

527527
def test_string_prompt_template_bypasses_reserved_key_validation(self):
528528
metric = LLMJudgeMetric(

packages/nemo_evaluator_sdk/tests/test_agent_inference.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def test_api_key_none_when_no_secret(self):
106106

107107
def test_extra_fields_forbidden(self):
108108
with pytest.raises(ValueError):
109-
Agent(url="http://agent.test", name="test", format=AgentFormat.NEMO_AGENT_TOOLKIT, extra_field="bad") # type: ignore[call-arg]
109+
Agent(url="http://agent.test", name="test", format=AgentFormat.NEMO_AGENT_TOOLKIT, extra_field="bad") # ty: ignore[unknown-argument]
110110

111111
def test_generic_with_trajectory_path(self):
112112
agent = Agent(

packages/nemo_platform_plugin/src/nemo_platform_plugin/_spec_flags.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ def _extract_default(info: FieldInfo) -> Any:
326326
return info.default
327327
if info.default_factory is not None:
328328
try:
329-
return info.default_factory() # type: ignore[call-arg]
329+
return info.default_factory() # ty: ignore[missing-argument]
330330
except TypeError:
331331
# Pydantic supports validated_data-aware factories; we can't
332332
# safely call those at CLI-build time. Treat as required so
@@ -451,7 +451,7 @@ def _optional_of(tp: object) -> Any:
451451
runtime value. Delegating to ``__getitem__`` here keeps the annotation
452452
correct without tripping static type checkers.
453453
"""
454-
return Optional[tp] # type: ignore[valid-type]
454+
return Optional[tp] # ty: ignore[invalid-type-form]
455455

456456

457457
def make_field_param(

packages/nemo_platform_plugin/src/nemo_platform_plugin/function.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ class NemoFunction(_NamedPlugin, Generic[SpecT]):
180180
# ``spec_schema`` to ``type[GreetSpec]`` for type-checkers and IDEs.
181181
# PEP 526 forbids type variables inside ``ClassVar``, so the suppression
182182
# here is the standard escape hatch for the otherwise-correct shape.
183-
spec_schema: ClassVar[type[SpecT]] # type: ignore[misc]
183+
spec_schema: ClassVar[type[SpecT]] # ty: ignore[invalid-type-form]
184184

185185
# ------------------------------------------------------------------ #
186186
# Endpoint override #

packages/nemo_platform_plugin/tests/test_dispatcher.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def test_returns_1_for_none_return(self, monkeypatch, tmp_path: Path) -> None:
170170
class _Job(NemoJob):
171171
name = "forgot-return"
172172

173-
def run(self, config: dict) -> dict: # type: ignore[return]
173+
def run(self, config: dict) -> dict: # ty: ignore[empty-body]
174174
# Intentionally no return — most plausible failure mode.
175175
pass
176176

packages/nemo_platform_plugin/tests/test_function_context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def test_with_request_id() -> None:
3030
def test_kw_only_construction() -> None:
3131
"""Workspace must be passed by keyword — the dataclass is ``kw_only``."""
3232
with pytest.raises(TypeError):
33-
FunctionContext("default") # type: ignore[misc] — intentional misuse
33+
FunctionContext("default") # ty: ignore[missing-argument,too-many-positional-arguments] — intentional misuse
3434

3535

3636
def test_field_set_is_minimal() -> None:

packages/nemo_platform_plugin/tests/test_inference_middleware.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ def test_config_id_reference(self):
394394

395395
def test_config_type_required(self):
396396
with pytest.raises(ValidationError):
397-
MiddlewareCall(name="nemo-switchyard") # type: ignore[call-arg]
397+
MiddlewareCall(name="nemo-switchyard") # ty: ignore[missing-argument]
398398

399399

400400
# ---------------------------------------------------------------------------

packages/nemo_platform_plugin/tests/test_job_context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,4 @@ def test_results_is_required(self, tmp_path: Path) -> None:
5858
# Omitting ``results`` raises at construction; the dataclass
5959
# enforces it (no silent ``None`` handed to the job).
6060
with pytest.raises(TypeError, match="results"):
61-
JobContext(workspace="ws", storage=_make_storage(tmp_path)) # type: ignore[call-arg]
61+
JobContext(workspace="ws", storage=_make_storage(tmp_path)) # ty: ignore[missing-argument]

0 commit comments

Comments
 (0)