More typing#268
Draft
nstarman wants to merge 6 commits into
Draft
Conversation
Add `@overload` signatures to `Function.__get__` so type checkers can distinguish class-level access (returns `Function`) from instance-level access (returns `MethodType`). Add `tests/static/function_get.pyi` with `assert_type` checks covering both access modes and the `@plum.dispatch` return-type preservation. Signed-off-by: nstarman <nstarman@users.noreply.github.com>
Introduces `_BoundFunctionProto` as the declared type of `_BoundFunction._f` instead of `Function` directly. This prevents mypy from applying `Function.__get__`'s descriptor protocol when resolving instance-attribute accesses of `_f`, eliminating the need for `# type: ignore[union-attr]` and `# type: ignore[return-value]` suppressions in `_BoundFunction`. Signed-off-by: nstarman <nstarman@users.noreply.github.com>
Coverage Report for CI Build 25586489844Coverage decreased (-0.009%) to 99.497%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
Signed-off-by: nstarman <nstarman@users.noreply.github.com>
…checks Add return types and parameter annotations to `ParametricTypeMeta` methods, `CovariantMeta` methods, and helpers in `_parametric.py`. Also add `_parametric.py` to the mypy-checked files list in `pyproject.toml`. Signed-off-by: nstarman <nstarman@users.noreply.github.com>
- Replace `cast(Callable[..., type], meta)(...)` with direct `meta(...)` calls using `meta: Any` - Access `__new__` via intermediate `_new: Any` variable to satisfy mypy descriptor checks - Remove stray blank line after docstring Signed-off-by: nstarman <nstarman@users.noreply.github.com>
wesselb
approved these changes
May 13, 2026
Member
wesselb
left a comment
There was a problem hiding this comment.
Looks great!! Left a few questions. Besides the questions, happy to merge whenever you're happy too :)
Co-authored-by: Wessel <wessel.p.bruinsma@gmail.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.
Improves the typing.
One API change is that
parametriccan't take None anymore. It couldn't before, but now it really can't.