Repository navigation
Add type hints, py.typed marker and strict mypy - #49
Merged
Merged
Conversation
## Summary The package had partial annotations and no `py.typed` marker, so downstream type checkers treated it as untyped. ## Changes - Annotate every function, method and class in `pylogkit/log_setup.py`: `ParamSpec` and `TypeVar` keep the signature of functions wrapped by `log_duration`, and `tqdm_logging` is generic over the iterable's item type. - Ship a PEP 561 `py.typed` marker, listed as package data. - Enable `strict = true` for mypy. Targeted `type: ignore` comments cover subclassing the untyped `colorlog` and `python-json-logger` classes, and use `unused-ignore` so they pass whether or not the libraries are typed. - CI checks that the built wheel contains `py.typed`. - Tests: marker present, package data configured, and every public callable fully annotated. ## Verification - `mypy --strict` is clean with the latest dependencies, with no extras, and `ruff` is clean. - `pytest`: 99 passed (latest dependencies) and 81 passed with 18 skipped (no extras). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01U2nYHVGDdthQpcwNBPbp8r
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01U2nYHVGDdthQpcwNBPbp8r
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
The package had partial annotations and no
py.typedmarker, so downstream type checkers treated it as untyped.Changes
pylogkit/log_setup.py:ParamSpecandTypeVarkeep the signature of functions wrapped bylog_duration, andtqdm_loggingis generic over the iterable's item type.py.typedmarker, listed as package data.strict = truefor mypy. Targetedtype: ignorecomments cover subclassing the untypedcolorlogandpython-json-loggerclasses, and useunused-ignoreso they pass whether or not the libraries are typed.py.typed.Verification
mypy --strictis clean with the latest dependencies, with no extras, andruffis clean.pytest: 99 passed (latest dependencies) and 81 passed with 18 skipped (no extras).Closes #19
🤖 Generated with Claude Code
https://claude.ai/code/session_01U2nYHVGDdthQpcwNBPbp8r
Generated by Claude Code