-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow self binding for generic ParamSpec #17123
base: master
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
Primer result analysis: antidoteThey use a custom dependency injection and function overload to remove the first argument with werkzeugThe error comes down to this class A:
import json
json_dumps = staticmethod(json.dumps)
def func(self, j: str) -> None:
self.json_dumps(j) Mypy doesn't recognize that ibisFalse positive which is removed. |
fd4a62a
to
83f3482
Compare
Diff from mypy_primer, showing the effect of this PR on open source code: ibis (https://github.com/ibis-project/ibis)
- ibis/expr/types/relations.py:3251: error: Missing positional argument "predicates" in call to "__call__" of "_Wrapped" [call-arg]
xarray (https://github.com/pydata/xarray)
+ xarray/tests/test_formatting_html.py: note: In member "test_empty_mapping" of class "Test_summarize_datatree_children":
+ xarray/tests/test_formatting_html.py:268: error: Invalid self argument "Test_summarize_datatree_children" to attribute function "func" with type "Callable[[Mapping[str, DataTree[Any]]], None]" [misc]
+ xarray/tests/test_formatting_html.py:268: error: Too many arguments [call-arg]
+ xarray/tests/test_formatting_html.py: note: In member "test_one_child" of class "Test_summarize_datatree_children":
+ xarray/tests/test_formatting_html.py:289: error: Invalid self argument "Test_summarize_datatree_children" to attribute function "func" with type "Callable[[Mapping[str, DataTree[Any]]], None]" [misc]
+ xarray/tests/test_formatting_html.py:289: error: Too many arguments [call-arg]
+ xarray/tests/test_formatting_html.py: note: In member "test_two_children" of class "Test_summarize_datatree_children":
+ xarray/tests/test_formatting_html.py:316: error: Invalid self argument "Test_summarize_datatree_children" to attribute function "func" with type "Callable[[Mapping[str, DataTree[Any]]], None]" [misc]
+ xarray/tests/test_formatting_html.py:316: error: Too many arguments [call-arg]
+ xarray/tests/test_formatting_html.py: note: In member "test_end" of class "Test__wrap_datatree_repr":
+ xarray/tests/test_formatting_html.py:335: error: Invalid self argument "Test__wrap_datatree_repr" to attribute function "func" with type "Callable[[str, bool], None]" [misc]
+ xarray/tests/test_formatting_html.py:335: error: Function gets multiple values for keyword argument "end" [misc]
+ xarray/tests/test_formatting_html.py: note: In member "test_not_end" of class "Test__wrap_datatree_repr":
+ xarray/tests/test_formatting_html.py:367: error: Invalid self argument "Test__wrap_datatree_repr" to attribute function "func" with type "Callable[[str, bool], None]" [misc]
+ xarray/tests/test_formatting_html.py:367: error: Function gets multiple values for keyword argument "end" [misc]
- xarray/tests/test_plot.py:226: error: Missing positional argument "self" in call to "__call__" of "_Wrapped" [call-arg]
- xarray/tests/test_plot.py:229: error: Missing positional argument "self" in call to "__call__" of "_Wrapped" [call-arg]
- xarray/tests/test_plot.py:232: error: Missing positional argument "self" in call to "__call__" of "_Wrapped" [call-arg]
+ xarray/tests/test_plot.py:226: error: Invalid self argument "DataArrayPlotAccessor" to attribute function "__call__" with type "Callable[[DataArray, DefaultNamedArg(Hashable | None, 'row'), DefaultNamedArg(Hashable | None, 'col'), DefaultNamedArg(int | None, 'col_wrap'), DefaultNamedArg(Any | None, 'ax'), DefaultNamedArg(Hashable | None, 'hue'), DefaultNamedArg(dict[str, Any] | None, 'subplot_kws'), KwArg(Any)], None]" [misc]
+ xarray/tests/test_plot.py:229: error: Invalid self argument "DataArrayPlotAccessor" to attribute function "__call__" with type "Callable[[DataArray, DefaultNamedArg(Hashable | None, 'row'), DefaultNamedArg(Hashable | None, 'col'), DefaultNamedArg(int | None, 'col_wrap'), DefaultNamedArg(Any | None, 'ax'), DefaultNamedArg(Hashable | None, 'hue'), DefaultNamedArg(dict[str, Any] | None, 'subplot_kws'), KwArg(Any)], None]" [misc]
+ xarray/tests/test_plot.py:232: error: Invalid self argument "DataArrayPlotAccessor" to attribute function "__call__" with type "Callable[[DataArray, DefaultNamedArg(Hashable | None, 'row'), DefaultNamedArg(Hashable | None, 'col'), DefaultNamedArg(int | None, 'col_wrap'), DefaultNamedArg(Any | None, 'ax'), DefaultNamedArg(Hashable | None, 'hue'), DefaultNamedArg(dict[str, Any] | None, 'subplot_kws'), KwArg(Any)], None]" [misc]
- xarray/tests/test_plot.py:235: error: Missing positional argument "self" in call to "__call__" of "_Wrapped" [call-arg]
+ xarray/tests/test_plot.py:235: error: Invalid self argument "DataArrayPlotAccessor" to attribute function "__call__" with type "Callable[[DataArray, DefaultNamedArg(Hashable | None, 'row'), DefaultNamedArg(Hashable | None, 'col'), DefaultNamedArg(int | None, 'col_wrap'), DefaultNamedArg(Any | None, 'ax'), DefaultNamedArg(Hashable | None, 'hue'), DefaultNamedArg(dict[str, Any] | None, 'subplot_kws'), KwArg(Any)], None]" [misc]
- xarray/tests/test_plot.py:245: error: Missing positional argument "self" in call to "__call__" of "_Wrapped" [call-arg]
- xarray/tests/test_plot.py:248: error: Missing positional argument "self" in call to "__call__" of "_Wrapped" [call-arg]
- xarray/tests/test_plot.py:252: error: Missing positional argument "self" in call to "__call__" of "_Wrapped" [call-arg]
- xarray/tests/test_plot.py:255: error: Missing positional argument "self" in call to "__call__" of "_Wrapped" [call-arg]
+ xarray/tests/test_plot.py:245: error: Invalid self argument "DataArrayPlotAccessor" to attribute function "__call__" with type "Callable[[DataArray, DefaultNamedArg(Hashable | None, 'row'), DefaultNamedArg(Hashable | None, 'col'), DefaultNamedArg(int | None, 'col_wrap'), DefaultNamedArg(Any | None, 'ax'), DefaultNamedArg(Hashable | None, 'hue'), DefaultNamedArg(dict[str, Any] | None, 'subplot_kws'), KwArg(Any)], None]" [misc]
+ xarray/tests/test_plot.py:248: error: Invalid self argument "DataArrayPlotAccessor" to attribute function "__call__" with type "Callable[[DataArray, DefaultNamedArg(Hashable | None, 'row'), DefaultNamedArg(Hashable | None, 'col'), DefaultNamedArg(int | None, 'col_wrap'), DefaultNamedArg(Any | None, 'ax'), DefaultNamedArg(Hashable | None, 'hue'), DefaultNamedArg(dict[str, Any] | None, 'subplot_kws'), KwArg(Any)], None]" [misc]
+ xarray/tests/test_plot.py:252: error: Invalid self argument "DataArrayPlotAccessor" to attribute function "__call__" with type "Callable[[DataArray, DefaultNamedArg(Hashable | None, 'row'), DefaultNamedArg(Hashable | None, 'col'), DefaultNamedArg(int | None, 'col_wrap'), DefaultNamedArg(Any | None, 'ax'), DefaultNamedArg(Hashable | None, 'hue'), DefaultNamedArg(dict[str, Any] | None, 'subplot_kws'), KwArg(Any)], None]" [misc]
+ xarray/tests/test_plot.py:255: error: Invalid self argument "DataArrayPlotAccessor" to attribute function "__call__" with type "Callable[[DataArray, DefaultNamedArg(Hashable | None, 'row'), DefaultNamedArg(Hashable | None, 'col'), DefaultNamedArg(int | None, 'col_wrap'), DefaultNamedArg(Any | None, 'ax'), DefaultNamedArg(Hashable | None, 'hue'), DefaultNamedArg(dict[str, Any] | None, 'subplot_kws'), KwArg(Any)], None]" [misc]
- xarray/tests/test_plot.py:266: error: Missing positional argument "self" in call to "__call__" of "_Wrapped" [call-arg]
- xarray/tests/test_plot.py:270: error: Missing positional argument "self" in call to "__call__" of "_Wrapped" [call-arg]
+ xarray/tests/test_plot.py:266: error: Invalid self argument "DataArrayPlotAccessor" to attribute function "__call__" with type "Callable[[DataArray, DefaultNamedArg(Hashable | None, 'row'), DefaultNamedArg(Hashable | None, 'col'), DefaultNamedArg(int | None, 'col_wrap'), DefaultNamedArg(Any | None, 'ax'), DefaultNamedArg(Hashable | None, 'hue'), DefaultNamedArg(dict[str, Any] | None, 'subplot_kws'), KwArg(Any)], None]" [misc]
+ xarray/tests/test_plot.py:270: error: Invalid self argument "DataArrayPlotAccessor" to attribute function "__call__" with type "Callable[[DataArray, DefaultNamedArg(Hashable | None, 'row'), DefaultNamedArg(Hashable | None, 'col'), DefaultNamedArg(int | None, 'col_wrap'), DefaultNamedArg(Any | None, 'ax'), DefaultNamedArg(Hashable | None, 'hue'), DefaultNamedArg(dict[str, Any] | None, 'subplot_kws'), KwArg(Any)], None]" [misc]
- xarray/tests/test_plot.py:304: error: Missing positional argument "self" in call to "__call__" of "_Wrapped" [call-arg]
- xarray/tests/test_plot.py:307: error: Missing positional argument "self" in call to "__call__" of "_Wrapped" [call-arg]
+ xarray/tests/test_plot.py:304: error: Invalid self argument "DataArrayPlotAccessor" to attribute function "__call__" with type "Callable[[DataArray, DefaultNamedArg(Hashable | None, 'row'), DefaultNamedArg(Hashable | None, 'col'), DefaultNamedArg(int | None, 'col_wrap'), DefaultNamedArg(Any | None, 'ax'), DefaultNamedArg(Hashable | None, 'hue'), DefaultNamedArg(dict[str, Any] | None, 'subplot_kws'), KwArg(Any)], None]" [misc]
+ xarray/tests/test_plot.py:307: error: Invalid self argument "DataArrayPlotAccessor" to attribute function "__call__" with type "Callable[[DataArray, DefaultNamedArg(Hashable | None, 'row'), DefaultNamedArg(Hashable | None, 'col'), DefaultNamedArg(int | None, 'col_wrap'), DefaultNamedArg(Any | None, 'ax'), DefaultNamedArg(Hashable | None, 'hue'), DefaultNamedArg(dict[str, Any] | None, 'subplot_kws'), KwArg(Any)], None]" [misc]
- xarray/tests/test_plot.py:317: error: Missing positional argument "self" in call to "__call__" of "_Wrapped" [call-arg]
+ xarray/tests/test_plot.py:317: error: Invalid self argument "DataArrayPlotAccessor" to attribute function "__call__" with type "Callable[[DataArray, DefaultNamedArg(Hashable | None, 'row'), DefaultNamedArg(Hashable | None, 'col'), DefaultNamedArg(int | None, 'col_wrap'), DefaultNamedArg(Any | None, 'ax'), DefaultNamedArg(Hashable | None, 'hue'), DefaultNamedArg(dict[str, Any] | None, 'subplot_kws'), KwArg(Any)], None]" [misc]
- xarray/tests/test_plot.py:389: error: Missing positional argument "self" in call to "__call__" of "_Wrapped" [call-arg]
+ xarray/tests/test_plot.py:389: error: Invalid self argument "DataArrayPlotAccessor" to attribute function "__call__" with type "Callable[[DataArray, DefaultNamedArg(Hashable | None, 'row'), DefaultNamedArg(Hashable | None, 'col'), DefaultNamedArg(int | None, 'col_wrap'), DefaultNamedArg(Any | None, 'ax'), DefaultNamedArg(Hashable | None, 'hue'), DefaultNamedArg(dict[str, Any] | None, 'subplot_kws'), KwArg(Any)], None]" [misc]
- xarray/tests/test_plot.py:519: error: Missing positional argument "self" in call to "__call__" of "_Wrapped" [call-arg]
... (truncated 117 lines) ...
antidote (https://github.com/Finistere/antidote)
+ tests/test_examples.py:37: error: Invalid self argument "Files" to attribute function "read" with type "Callable[[str], None]" [misc]
+ tests/test_examples.py:37: error: Too many arguments [call-arg]
+ tests/test_examples.py:41: error: Invalid self argument "Files" to attribute function "read" with type "Callable[[str], None]" [misc]
+ tests/test_examples.py:41: error: Too many arguments [call-arg]
+ tests/core/test_inject.py:517: error: Attribute function "method" with type "Callable[[], None]" does not accept self argument [misc]
+ tests/core/test_inject.py:519: error: Invalid self argument "Conf" to attribute function "get" with type "Callable[[str], None]" [misc]
+ tests/core/test_inject.py:519: error: Too many arguments [call-arg]
+ tests/core/test_inject.py:522: error: Attribute function "method" with type "Callable[[], None]" does not accept self argument [misc]
+ tests/core/test_inject.py:523: error: Invalid self argument "Conf" to attribute function "get" with type "Callable[[str], None]" [misc]
+ tests/core/test_inject.py:523: error: Unexpected keyword argument "key" [call-arg]
werkzeug (https://github.com/pallets/werkzeug)
+ src/werkzeug/test.py:370: error: Too many positional arguments [misc]
+ src/werkzeug/test.py:370: error: Argument 1 has incompatible type "Mapping[str, Any]"; expected "bool" [arg-type]
|
Great work! Do you think we can get any reviews on this one? |
Required for python/typeshed#11662
Discussion: https://discuss.python.org/t/allow-self-binding-for-generic-paramspec/50948