feat: add type hints and py.typed marker (#18)#19
Merged
Conversation
Convert the single-module distribution into a package and ship a PEP 561 py.typed marker so type checkers (Pylance/pyright) pick up the inline type hints, resolving the reportMissingTypeStubs warning reported in #18. - mmdb_writer.py -> mmdb_writer/__init__.py + py.typed marker - Add complete type annotations across public and internal APIs (overloaded Encoder.encode, TreeChild alias, generic params, etc.) - Fix latent typing issues: languages default, int/float_type literal widening, bits_rstrip default - Add pyright to dev deps with [tool.pyright] config (standard, py3.9) - Run pyright as a Type check step in CI and publish workflows - Bump version to 0.2.7 Closes #18 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Background
Closes #18 — Pylance reports
reportMissingTypeStubs("Fichier stub introuvable pour « mmdb_writer »"). The root cause is that the published package ships no PEP 561py.typedmarker, so type checkers won't trust the inline type hints the library already had.Changes
mmdb_writer.py→mmdb_writer/__init__.py, plus a newmmdb_writer/py.typed. Import paths are unchanged (from mmdb_writer import MMDBWriter, ...).Encoder.encodeuses@overloadto distinguishreturn_offset=True → intfrom the default→ bytesTreeChildalias expressingSearchTreeNode's "node | leaf | empty" child statesdict[str, Any],list[Any], etc.)languages=None→Optional[...],int_type/float_typeliteral widening,bits_rstripdefault value.pyrightto the dev deps with a[tool.pyright]config (standard / pythonVersion 3.9), and aType checkstep in both the CI and publish workflows.0.2.7.Verification
pyright(standard, py3.9)ruff check+format --checkpytest tests/test_api.pypy.typedVerified in a clean venv with the built wheel installed: the Pylance/pyright
reportMissingTypeStubswarning is gone, andreveal_typeshows the full signatures.🤖 Generated with Claude Code