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

Add stubs for some missing imports #617

Closed
wants to merge 9 commits into from

Conversation

bhrutledge
Copy link
Contributor

@bhrutledge bhrutledge commented May 9, 2020

Related to #231

Okay, this is definitely yak-shaving, but I was curious how hard it might be to add our own stubs, and what value they might bring. If nothing else, I found it to be an informative exercise, and thought others might as well. Before I go further, I'm curious if there's any appetite for merging something like this.

Changes:

  • Add stubs for the bits of the pkginfo and importlib_metadata API that twine uses
  • Fix resulting mypy errors
  • Add formatting and linting for stubs (incomplete)
  • Type coverage: https://twine-mypy.now.sh/
+-------------------------+-------------------+-------------------+
| Module                  | Before            | After             |
+-------------------------+-------------------+-------------------+
| twine                   |  22.73% imprecise |   2.27% imprecise |
| twine._installed        |  10.00% imprecise |   8.33% imprecise |
| twine.cli               |  17.81% imprecise |  13.51% imprecise |
| twine.package           |  17.10% imprecise |   1.48% imprecise |
| twine.repository        |  16.73% imprecise |  16.34% imprecise |
| twine.wheel             |   7.61% imprecise |   2.15% imprecise |
| twine.wininst           |   3.28% imprecise |   1.64% imprecise |
+-------------------------+-------------------+-------------------+
| Total                   |   8.95% imprecise |   5.99% imprecise |
+-------------------------+-------------------+-------------------+

TODO:

  • Review typeshed/CONTRIBUTING.md for stub code style
  • Rework linting/formatting for stubs. I don't think the flake8 configuration is right. I tried flake8-pyi, but saw some inconsistent behavior, though it might be worth a closer look.
  • Maybe: Add stubs for more missing imports

@bhrutledge
Copy link
Contributor Author

Since nobody has said this is a great idea, and it's probably more than we want to maintain, I'm closing this. We can revive it later if there's interest.

@bhrutledge bhrutledge closed this May 23, 2020
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.

None yet

1 participant