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 a py.typed file #1316

Closed
neighthan opened this issue Mar 25, 2020 · 4 comments · Fixed by #1395
Closed

Add a py.typed file #1316

neighthan opened this issue Mar 25, 2020 · 4 comments · Fixed by #1395
Labels
T: enhancement New feature or request

Comments

@neighthan
Copy link
Contributor

  • Problem: mypy can't find type hints when importing black
  • Solution: add a py.typed file to make black PEP-561-compatible
  • Alternatives: add black to typeshed or see my StackOverflow question for how I worked around this from the user's side (create py.typed in site-packages/black)
@neighthan neighthan added the T: enhancement New feature or request label Mar 25, 2020
@zsol
Copy link
Collaborator

zsol commented Mar 28, 2020

I've briefly looked into this. Being unfamiliar with PEP-561, I might be wrong so take this with a grain of salt. It looks like it's not possible to add py.typed without reorganizing the repo layout a bit. We'd need to create a black package, move black.py into black/__init__.py and create black/py.typed. At that point it would make sense to move blib2to3 into black/blib2to3 too.

@JelleZijlstra
Copy link
Collaborator

That's correct, PEP 561 only supports packages, not single-module libraries like Black.

@neighthan
Copy link
Contributor Author

Are there any particular benefits of having black not be a package?

@cooperlees
Copy link
Collaborator

Please follow #1350 for the discussion about refactor of black.py into a black/ package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T: enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants