Experiment: Can we use ParamSpec in functools.wraps yet?#11
Closed
AlexWaygood wants to merge 3 commits intomasterfrom
Closed
Experiment: Can we use ParamSpec in functools.wraps yet?#11AlexWaygood wants to merge 3 commits intomasterfrom
ParamSpec in functools.wraps yet?#11AlexWaygood wants to merge 3 commits intomasterfrom
Conversation
This comment has been minimized.
This comment has been minimized.
|
Linking this back to the discussion at python@7d987a1#commitcomment-127920750 for reference (since it's hard to find comments on commits) |
ParamSpec in functools.wraps yet?
ilevkivskyi
added a commit
to python/mypy
that referenced
this pull request
Sep 27, 2023
…16178) This should help with re-enabling the use of `ParamSpec` in `functools.wraps` (as it looks like some of the new errors in AlexWaygood#11 are caused by not handling this). --------- Co-authored-by: hauntsaninja <hauntsaninja@gmail.com> Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
|
Diff from mypy_primer, showing the effect of this PR on open source code: prefect (https://github.com/PrefectHQ/prefect)
- src/prefect/utilities/asyncutils.py:218: error: Argument 1 to "wraps" has incompatible type "T"; expected "Callable[..., object]" [arg-type]
+ src/prefect/utilities/asyncutils.py:218: error: Argument 1 to "wraps" has incompatible type "T"; expected "Callable[[VarArg(Never), KwArg(Never)], Never]" [arg-type]
+ src/prefect/utilities/asyncutils.py:260: error: Need type annotation for "wrapper" [var-annotated]
- src/prefect/utilities/asyncutils.py:266: error: "Callable[[VarArg(Any), KwArg(Any)], Any]" has no attribute "aio" [attr-defined]
+ src/prefect/utilities/asyncutils.py:266: error: "_Wrapped[Any, Any, [VarArg(Any), KwArg(Any)], Any]" has no attribute "aio" [attr-defined]
- src/prefect/utilities/asyncutils.py:267: error: Incompatible return value type (got "Callable[[VarArg(Any), KwArg(Any)], Any]", expected "T") [return-value]
+ src/prefect/utilities/asyncutils.py:267: error: Incompatible return value type (got "_Wrapped[Any, Any, [VarArg(Any), KwArg(Any)], Any]", expected "T") [return-value]
jax (https://github.com/google/jax)
+ jax/_src/maps.py:626: error: Incompatible return value type (got "_Wrapped[[VarArg(Any), KwArg(Any)], Any, [VarArg(Any), KwArg(Any)], Any]", expected "Wrapped") [return-value]
+ jax/_src/maps.py:626: note: "_Wrapped" is missing following "Wrapped" protocol member:
+ jax/_src/maps.py:626: note: lower
ibis (https://github.com/ibis-project/ibis)
- ibis/expr/deferred.py:317: error: Incompatible return value type (got "Callable[[VarArg(Any), KwArg(Any)], Any]", expected "F") [return-value]
+ ibis/expr/deferred.py:317: error: Incompatible return value type (got "_Wrapped[[VarArg(Any), KwArg(Any)], Any, [VarArg(Any), KwArg(Any)], Any]", expected "F") [return-value]
tornado (https://github.com/tornadoweb/tornado)
+ tornado/gen.py:268: error: Unused "type: ignore" comment [unused-ignore]
nox (https://github.com/wntrblm/nox)
+ nox/_decorators.py:54: error: Incompatible types in assignment (expression has type "_Wrapped[[VarArg(Any), KwArg(Any)], Any, [VarArg(Any), KwArg(Any)], Any]", variable has type "FunctionType") [assignment]
bokeh (https://github.com/bokeh/bokeh)
+ src/bokeh/document/callbacks.py: note: In member "add_session_callback" of class "DocumentCallbackManager":
+ src/bokeh/document/callbacks.py:185:31: error: Incompatible types in assignment (expression has type "Callable[[], None]", variable has type "_Wrapped[[], None, [], None]") [assignment]
mitmproxy (https://github.com/mitmproxy/mitmproxy): typechecking got 1.44x slower (37.2s -> 53.6s)
(Performance measurements are based on a single noisy sample)
jinja (https://github.com/pallets/jinja)
+ src/jinja2/compiler.py:56: error: Incompatible return value type (got "_Wrapped[[VarArg(Any), KwArg(Any)], Any, [VarArg(Any), KwArg(Any)], Any]", expected "F") [return-value]
hydra-zen (https://github.com/mit-ll-responsible-ai/hydra-zen)
- src/hydra_zen/wrapper/_implementations.py:456: error: Incompatible types in assignment (expression has type "Zen[P, R]", variable has type "Callable[[Any], Any]") [assignment]
+ src/hydra_zen/wrapper/_implementations.py:456: error: Incompatible types in assignment (expression has type "Zen[P, R]", variable has type "_Wrapped[P, R, [Any], Any]") [assignment]
- src/hydra_zen/wrapper/_implementations.py:456: note: "Zen[P, R].__call__" has type "Callable[[DataClass_ | type[DataClass_] | dict[Any, Any] | DictConfig | str], R]"
|
Owner
Author
|
Looks like python@d25d680 cut two errors off the diff @ilevkivskyi. But tbh, I'm still not sure what using ParamSpec here gets us, and it's still causing new errors in four projects |
Owner
Author
|
We now use |
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.
No description provided.