Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,4 @@ invalid-return-type = "ignore" # Return type mismatches that would requi
deprecated = "ignore" # Deprecation warnings from dependencies
invalid-assignment = "ignore" # Low-level assignments that are runtime-safe
unused-ignore-comment = "ignore" # Ignore comments that became unnecessary after adding broader per-file-ignores
unused-type-ignore-comment = "ignore" # A `# type: ignore` counts as "used" only when its suppressed error fires, which needs optional deps (torch, openai, ...) installed. CI's lean `quality` env lacks them, so directives used locally look unused in CI.
33 changes: 10 additions & 23 deletions utils/check_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,14 @@
# - `check_args` below are the exact roots passed to `ty check`.
# - `cache_globs` here are only used by `utils/checkers.py` to decide when a
# previously clean `types` run can be reused from cache.
# Approximate: ty follows imports beyond the listed directories; these globs cover
# the explicitly targeted paths but not transitive dependencies.
# ty follows imports *beyond* the checked roots, so the cache key must cover every source file
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

but the scope is always within src/transformers, right? i.e. it will never go beyond this?

Copy link
Copy Markdown
Collaborator Author

@tarekziade tarekziade May 29, 2026

Choose a reason for hiding this comment

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

yes, but we check a subset of the files in that directory with our set up.
the change makes sure that we bust the cache in case ANY file has changed because it can indirectly impact the ty call.

# that could change a result -- not just the explicitly-checked paths. We hash the whole package
# (plus the standalone .circleci target) so any source edit busts the cache and forces a
# re-check. Otherwise a cached pass could silently hide a newly-introduced error in a
# transitively-imported module that ty pulls in but that isn't one of the checked roots.
"cache_globs": [
"src/transformers/_typing.py",
"src/transformers/cli/**/*.py",
"src/transformers/modeling_utils.py",
"src/transformers/utils/**/*.py",
"src/transformers/generation/**/*.py",
"src/transformers/pipelines/__init__.py",
"src/transformers/pipelines/feature_extraction.py",
"src/transformers/pipelines/image_feature_extraction.py",
"src/transformers/pipelines/video_classification.py",
"src/transformers/quantizers/**/*.py",
"src/transformers/**/*.py",
".circleci/create_circleci_config.py",
"src/transformers/dependency_versions_table.py",
"src/transformers/dependency_versions_check.py",
"src/transformers/conversion_mapping.py",
"src/transformers/time_series_utils.py",
"src/transformers/debug_utils.py",
"src/transformers/hyperparameter_search.py",
"src/transformers/pytorch_utils.py",
"src/transformers/file_utils.py",
"src/transformers/trainer_jit_checkpoint.py",
"src/transformers/trainer_optimizer.py",
],
"check_args": [
"src/transformers/_typing.py",
Expand Down Expand Up @@ -74,8 +58,11 @@ def main():

directories = sys.argv[1:]
print(f"Running ty check on: {', '.join(directories)}")
# `--error-on-warning` makes ty exit non-zero on warning-level diagnostics (e.g.
# possibly-missing-attribute), not just errors. Without it, warnings print but ty exits 0, so
# `make typing` and CI both pass and the issue is never caught before commit.
result = subprocess.run(
["ty", "check", "--respect-ignore-files", "--exclude", "**/*_pb*", *directories],
["ty", "check", "--respect-ignore-files", "--error-on-warning", "--exclude", "**/*_pb*", *directories],
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Locally, we have this --error-on-warning but not on current CI ??
Or I misunderstand the inconsistency you described?

I noticed make typing was failing locally but the ty checker was green in CI. This happened because the CI run did not error on warnings.

Copy link
Copy Markdown
Collaborator Author

@tarekziade tarekziade May 29, 2026

Choose a reason for hiding this comment

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

it was a combination:

  • no error on warnings
  • the local can have more packages installed : torch, torchvision, etc

the combo made the two environments behave differently when warnings where triggered.

)
sys.exit(result.returncode)

Expand Down
Loading