Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

timm: add __all__ to __init__ #2399

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

adamjstewart
Copy link

This fixes mypy errors on files like:

import timm

timm.create_model("resnet18")

The error can be reproduced using:

> mypy --strict test.py
test.py:3: error: Module "timm" does not explicitly export attribute "create_model"  [attr-defined]
Found 1 error in 1 file (checked 1 source file)

@rwightman
Copy link
Collaborator

Does something like __all__ = [name for name in locals() if not name.startswith('_')] keep mypy happy? because redefining everything in __init__.py in __all__ is extremely redundant and just adds to maint burden.

@adamjstewart
Copy link
Author

Unfortunately that doesn't work for mypy, flake8, ruff, or any other static style checker as it is dynamically generated.

The maintenance burden depends on how often you update __init__ and whether or not you use tools like mypy/flake8/ruff to enforce it. FWIW, I'm willing to help maintain this myself, and can update all __init__.py files for you if you'll let me add one of the above tools to make sure it stays up to date. I would also be interested in avoiding star imports as well.

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