Skip to content

Commit d927c6c

Browse files
committed
Fix MYPY lint: key the torch import exemption on the imported module
The [mypy-.github.scripts.build_report] section never matched: with no __init__.py in that directory mypy names the module build_report, not the dotted path, so import-not-found was still reported for torch and torchvision. Use ignore_missing_imports on the imported modules instead, which is how mypy resolves third-party modules that are absent from the lint environment. Verified with mypy 1.13.0 (the pinned version) against mypy.ini: clean.
1 parent 3edf8f3 commit d927c6c

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

mypy.ini

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@ disable_error_code = attr-defined, return-value
1515
[mypy-.github.scripts.run_with_env_secrets]
1616
disable_error_code = attr-defined, return-value, union-attr
1717

18-
[mypy-.github.scripts.build_report]
19-
# torch/torchvision are not installed in the lint environment; the script
20-
# imports them defensively at runtime and degrades when they are absent.
21-
disable_error_code = import-not-found, import-untyped
22-
2318
[mypy-aws.lambda.whl_metadata_upload_pep658.lambda_function]
2419
disable_error_code = unused-ignore, import-not-found
2520

@@ -75,4 +70,12 @@ disable_error_code = var-annotated, import-untyped
7570
disable_error_code = index, no-redef, no-untyped-def, import-not-found, no-untyped-call
7671

7772
[mypy-tools.rockset_migration.*]
78-
disable_error_code = arg-type, attr-defined, return-value, misc, func-returns-value, no-untyped-def, assignment, var-annotated, unused-ignore, truthy-function
73+
disable_error_code = arg-type, attr-defined, return-value, misc, func-returns-value, no-untyped-def, assignment, var-annotated, unused-ignore, truthy-function
74+
75+
# torch and torchvision are not installed in the lint environment. Scripts that
76+
# import them do so defensively at runtime and degrade when they are absent.
77+
[mypy-torch.*]
78+
ignore_missing_imports = True
79+
80+
[mypy-torchvision.*]
81+
ignore_missing_imports = True

0 commit comments

Comments
 (0)