Black: Add a py.typed file

Created on 25 Mar 2020  路  4Comments  路  Source: psf/black

  • 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)
enhancement

Most helpful comment

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

All 4 comments

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.

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

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

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dusty-phillips picture dusty-phillips  路  3Comments

decibyte picture decibyte  路  3Comments

JelleZijlstra picture JelleZijlstra  路  3Comments

dgnsrekt picture dgnsrekt  路  3Comments

nottrobin picture nottrobin  路  3Comments