Skip to content

[Quality] Fix uvx ty check src errors#4159

Merged
Wauplin merged 1 commit intomainfrom
fix-ty-check-errors
Apr 28, 2026
Merged

[Quality] Fix uvx ty check src errors#4159
Wauplin merged 1 commit intomainfrom
fix-ty-check-errors

Conversation

@Wauplin
Copy link
Copy Markdown
Contributor

@Wauplin Wauplin commented Apr 28, 2026

Summary

Latest ty release (0.0.33) flags two pre-existing diagnostics that older versions missed, breaking the uvx ty check src step in the python-quality CI workflow. Both reflect intentional dynamic patterns that ty cannot model statically, so we suppress them with targeted ignore comments.

  • _tensorboard_logger.py:41: assigning _DummySummaryWriter to _RuntimeSummaryWriter conflicts with the declared type from the earlier tensorboardX / torch.utils.tensorboard import branches. The # type: ignore[assignment] (mypy) was already there; added a matching # ty: ignore[conflicting-declarations].
  • hf_file_system.py:140: HfFileSystem uses a local _Cached metaclass that subclasses type(fsspec.AbstractFileSystem) at runtime. The subclass relationship holds at runtime but ty can't prove it statically — added # ty: ignore[conflicting-metaclass].

Before:

$ uvx ty check src
src/huggingface_hub/_tensorboard_logger.py:41:9: error[conflicting-declarations] Conflicting declared types for `_RuntimeSummaryWriter`: `Unknown` and `<class 'SummaryWriter'>`
src/huggingface_hub/hf_file_system.py:140:1: error[conflicting-metaclass] The metaclass of a derived class (`HfFileSystem`) must be a subclass of the metaclasses of all its bases, but `_Cached` (metaclass of `HfFileSystem`) and `_Cached` (metaclass of base class `AbstractFileSystem`) have no subclass relationship
Found 2 diagnostics

After:

$ uvx ty check src
All checks passed!

$ make quality
ruff check src tests utils setup.py  # linter
All checks passed!
...
ty check src
All checks passed!

$ mypy src/huggingface_hub/__init__.py --follow-imports=silent --show-traceback
Success: no issues found in 1 source file

🤖 Generated with Claude Code


Note

Low Risk
Low risk: only adds targeted # ty: ignore[...] comments to silence new static type-checker diagnostics, with no runtime logic changes.

Overview
Unblocks the uvx ty check src CI step by adding targeted ty suppression comments for two intentional dynamic patterns.

Specifically, it annotates the _DummySummaryWriter fallback assignment in _tensorboard_logger.py with # ty: ignore[conflicting-declarations], and marks HfFileSystem’s use of the custom _Cached metaclass in hf_file_system.py with # ty: ignore[conflicting-metaclass].

Reviewed by Cursor Bugbot for commit 6310f19. Bugbot is set up for automated code reviews on this repo. Configure here.

Latest ty (0.0.33) flags two pre-existing diagnostics that older versions
missed. Suppress them with targeted ignore comments since both reflect
intentional dynamic patterns ty cannot model.

- _tensorboard_logger.py: assigning _DummySummaryWriter to
  _RuntimeSummaryWriter conflicts with the declared type from the
  earlier import branches. The mypy ignore was already present;
  add a matching ty ignore.
- hf_file_system.py: HfFileSystem uses a local _Cached metaclass that
  subclasses type(fsspec.AbstractFileSystem) at runtime, but ty cannot
  prove the subclass relationship statically.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@bot-ci-comment
Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@Wauplin Wauplin merged commit 980da2c into main Apr 28, 2026
19 of 21 checks passed
@Wauplin Wauplin deleted the fix-ty-check-errors branch April 28, 2026 11:57
@huggingface-hub-bot
Copy link
Copy Markdown
Contributor

This PR has been shipped as part of the v1.13.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants