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
Add py.typed
file to gradio
package
#6396
Comments
Thanks @aleneum this seems like a helpful addition -- please go ahead and create the PR! |
Hello @abidlabs, it is (of course) not as straight forward as I have hoped for. Problem 1: Adding a Solution: I could create/touch 'py.typed' the moment a Problem 2: In templates.py, there are multiple classes commented out. The problem is that some/all of them contain an attribute named 'type'. Solution: I could comment out the relevant classes in templates.py TWICE and add a remark concerning this issue. The mentioned commits above did that. A generated gradio package including pyi files, py.typed and changes to templates.py works though. Let me know what you think and what would be in the best interest of the project. |
Hi @aleneum thanks for investigating this! I think both of those solutions are reasonable. Could you add the And also could you also add a |
see gradio-app#6396 for details
* comment out classes in templates TWICE see #6396 for details * add py.typed to hatch artifacts * add py.typed to gitignore * create py.typed in type_check_backend * add changeset * add changeset --------- Co-authored-by: Abubakar Abid <abubakar@huggingface.co> Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Is your feature request related to a problem? Please describe.
Whenever I use
mypy
I will get the following warning:As far as I know, there are no Gradio stubs and Gradio does not contain a
py.typed
file as well.A common workaround for untyped packages is to tell
mypy
to not follow such imports:However, when
disallow_any_unimported
is enabled,mypy
cannot type check functions with Gradio parameters:My current solution is to allow any imports whenever Gradio is used. However, as most
gradio
imports seem to be typed, why not just add apy.typed
file to the package to be PEP 561 compliant? This would make it easier to spot typing issues when working with Gradio.Describe the solution you'd like
Add an empty file
py.typed
to the package (<project>/gradio
) and include it via:I am happy to create a PR for this (hopefully trivial) change when you consider this useful.
The text was updated successfully, but these errors were encountered: