chore: add py.typed marker for PEP 561 typing support#11
Open
speckhard wants to merge 1 commit intoLeMaterial:mainfrom
Open
chore: add py.typed marker for PEP 561 typing support#11speckhard wants to merge 1 commit intoLeMaterial:mainfrom
speckhard wants to merge 1 commit intoLeMaterial:mainfrom
Conversation
Without this marker, downstream type checkers (mypy, pyright, pyre) ignore the hand-maintained .pyi stubs that ship alongside the package and collapse imported atompack symbols to Any. PEP 561 requires the marker for "inline" packages — packages that ship their stubs in the same directory as the runtime code, which is what atompack does (__init__.pyi, _atompack_rs.pyi, hub.pyi all live next to __init__.py). Maturin ships everything under python-source = "python" by default, so the new file lands in the wheel without any [tool.maturin] include change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add an empty
py.typedmarker file so downstream type checkers (mypy, pyright, pyre) actually pick up the hand-maintained.pyistubs shipped alongside the package.PEP 561 requires this marker for "inline" packages — packages that ship their stubs in the same directory as the runtime code, which is what atompack does. Without the marker, mypy / pyright treat every imported atompack symbol as
Any, even though the stubs are correct.Why no
pyproject.tomlchangeMaturin ships everything under
python-source = "python"by default. The new file is inatompack-py/python/atompack/py.typed, so it lands in the wheel without any[tool.maturin] includechange. The three.pyistubs already in that directory ship the same way today — confirmed by inspecting the publishedatompack-db==0.2.1wheel.Verification
Maturin packaging path. Inspected the current PyPI wheel:
The three
.pyistubs ship today viapython-source = "python". A siblingpy.typedrides the exact same path.End-to-end mypy check. Fresh Python 3.11 venv with the current PyPI wheel installed.
Before adding py.typed:
After
touch site-packages/atompack/py.typed:Confirms the marker is exactly what unlocks the existing stubs for downstream type checkers.
References