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

feat: allow stubs package #742

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

feat: allow stubs package #742

wants to merge 4 commits into from

Conversation

trim21
Copy link

@trim21 trim21 commented Apr 6, 2025

close #332

  • do not try to get docstring and version if it's not dynamic, which is typical the case of stubs package
  • do not raise exception if it's -stubs package without __init__.py
  • do not normalize the -stubs parts in package name

@trim21 trim21 marked this pull request as draft April 6, 2025 20:51
@trim21 trim21 marked this pull request as ready for review April 6, 2025 20:59
Comment on lines +514 to +515
if name.endswith('-stubs'):
return name.removesuffix('-stubs').replace('-','_') + '-stubs'
Copy link
Contributor

Choose a reason for hiding this comment

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

The special casing should be explained here. For example, typeshed uses a types- prefix, which this doesn't cover. Is that important?

Copy link
Author

@trim21 trim21 Apr 8, 2025

Choose a reason for hiding this comment

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

it's from pep-0561, a type stub package should add -stubs to main package.

the types- prefix is just the pypi name, which is not the director contains pyi files.

For example, if you unzip the types_six-1.17.0.20250403-py3-none-any.whl, you will get this:

Archive:  types_six-1.17.0.20250403-py3-none-any.whl
  inflating: six-stubs/METADATA.toml
  inflating: six-stubs/__init__.pyi
  inflating: six-stubs/py.typed
  inflating: six-stubs/moves/BaseHTTPServer.pyi
  inflating: six-stubs/moves/CGIHTTPServer.pyi
  inflating: six-stubs/moves/SimpleHTTPServer.pyi
  inflating: six-stubs/moves/__init__.pyi
  inflating: six-stubs/moves/_dummy_thread.pyi
...

AND, if you are not typeshed, you should not use types- prefix.

so we only handle -stubs here.

Copy link
Author

@trim21 trim21 Apr 8, 2025

Choose a reason for hiding this comment

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

It's still possible that a package named as something like pkg-stubs2 and contins pkg-stubs/__init__.pyi for package "pkg", but I don't think it's worth handling ...

only handle -stubs suffix should cover most of the use case. If someone need a package pkg-stubs, they can still workaround with solution at here: #332 (comment)

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.

Support stub-only packages?
2 participants