Add function definition notes for too_many_positional_arguments errors#21410
Add function definition notes for too_many_positional_arguments errors#21410KevinRK29 wants to merge 2 commits into
too_many_positional_arguments errors#21410Conversation
This comment has been minimized.
This comment has been minimized.
| @@ -972,6 +972,7 @@ def too_many_positional_arguments(self, callee: CallableType, context: Context) | |||
| msg = "Too many positional arguments" + for_function(callee) | |||
| self.fail(msg, context) | |||
There was a problem hiding this comment.
Looking at the primer, I think I may need to change it to self.fail(msg, context, code=codes.CALL_ARG) similar to the error cases above?
There was a problem hiding this comment.
Usually we try to avoid changing the error code. But in this case this looks like an oversight. I leave this up to @JukkaL to decide.
There was a problem hiding this comment.
Let's try switching to CALL_ARG and see if the mypy primer looks any worse. The current error code is inconsistent, so it's reasonable to change it if it doesn't cause a big fallout. If there are many new errors, we can use the misc error code for the note as well -- they both need to use the same error code.
There was a problem hiding this comment.
looking at the latest primer, it seems like a lot of these new errors are from the projects that had # type: ignore[misc] silencing this error but now that we changed the error code and cause of that, an unused-ignore error. Not sure if this is an acceptable amount of errors, but if not, I can update the note to use the misc error code as well.
|
Diff from mypy_primer, showing the effect of this PR on open source code: urllib3 (https://github.com/urllib3/urllib3)
+ test/with_dummyserver/test_poolmanager.py:659: error: Unused "type: ignore" comment [unused-ignore]
+ test/with_dummyserver/test_poolmanager.py:659: error: Too many positional arguments for "request" [call-arg]
+ test/with_dummyserver/test_poolmanager.py:659: note: Error code "call-arg" not covered by "type: ignore[misc]" comment
+ test/with_dummyserver/test_poolmanager.py:659: note: "request" defined in "urllib3"
pandas-stubs (https://github.com/pandas-dev/pandas-stubs)
+ tests/test_string_accessors.py:226: error: Unused "type: ignore" comment [unused-ignore]
+ tests/test_string_accessors.py:226: error: Too many positional arguments for "wrap" of "StringMethods" [call-arg]
+ tests/test_string_accessors.py:226: note: Error code "call-arg" not covered by "type: ignore[misc]" comment
+ tests/test_string_accessors.py:226: note: "wrap" defined in "pandas.core.strings.accessor"
+ tests/test_string_accessors.py:290: error: Unused "type: ignore" comment [unused-ignore]
+ tests/test_string_accessors.py:290: error: Too many positional arguments for "wrap" of "StringMethods" [call-arg]
+ tests/test_string_accessors.py:290: note: Error code "call-arg" not covered by "type: ignore[misc]" comment
+ tests/test_string_accessors.py:290: note: "wrap" defined in "pandas.core.strings.accessor"
+ tests/series/test_series.py:173: error: Unused "type: ignore" comment [unused-ignore]
+ tests/series/test_series.py:173: error: Too many positional arguments for "any" of "Series" [call-arg]
+ tests/series/test_series.py:173: note: Error code "call-arg" not covered by "type: ignore[misc]" comment
+ tests/series/test_series.py:173: note: "any" defined in "pandas.core.series"
+ tests/series/test_series.py:182: error: Unused "type: ignore" comment [unused-ignore]
+ tests/series/test_series.py:182: error: Too many positional arguments for "all" of "Series" [call-arg]
+ tests/series/test_series.py:182: note: Error code "call-arg" not covered by "type: ignore[misc]" comment
+ tests/series/test_series.py:182: note: "all" defined in "pandas.core.series"
+ tests/series/test_series.py:487: error: Unused "type: ignore" comment [unused-ignore]
+ tests/series/test_series.py:487: error: Too many positional arguments for "median" of "Series" [call-arg]
+ tests/series/test_series.py:487: note: Error code "call-arg" not covered by "type: ignore[misc]" comment
+ tests/series/test_series.py:487: note: "median" defined in "pandas.core.series"
+ tests/series/test_series.py:548: error: Unused "type: ignore" comment [unused-ignore]
+ tests/series/test_series.py:548: error: Too many positional arguments for "min" of "Series" [call-arg]
+ tests/series/test_series.py:548: note: Error code "call-arg" not covered by "type: ignore[misc]" comment
+ tests/series/test_series.py:548: note: "min" defined in "pandas.core.series"
+ tests/series/test_series.py:563: error: Unused "type: ignore" comment [unused-ignore]
+ tests/series/test_series.py:563: error: Too many positional arguments for "max" of "Series" [call-arg]
+ tests/series/test_series.py:563: note: Error code "call-arg" not covered by "type: ignore[misc]" comment
+ tests/series/test_series.py:563: note: "max" defined in "pandas.core.series"
+ tests/series/test_series.py:967: error: Unused "type: ignore" comment [unused-ignore]
+ tests/series/test_series.py:967: error: Too many positional arguments for "sum" of "Series" [call-arg]
+ tests/series/test_series.py:967: note: Error code "call-arg" not covered by "type: ignore[misc]" comment
+ tests/series/test_series.py:967: note: "sum" defined in "pandas.core.series"
+ tests/series/test_series.py:968: error: Unused "type: ignore" comment [unused-ignore]
+ tests/series/test_series.py:968: error: Too many positional arguments for "prod" of "Series" [call-arg]
+ tests/series/test_series.py:968: note: Error code "call-arg" not covered by "type: ignore[misc]" comment
+ tests/series/test_series.py:968: note: "prod" defined in "pandas.core.series"
+ tests/series/test_series.py:969: error: Unused "type: ignore" comment [unused-ignore]
+ tests/series/test_series.py:969: error: Too many positional arguments for "std" of "Series" [call-arg]
+ tests/series/test_series.py:969: note: Error code "call-arg" not covered by "type: ignore[misc]" comment
+ tests/series/test_series.py:969: note: "std" defined in "pandas.core.series"
+ tests/series/test_series.py:970: error: Unused "type: ignore" comment [unused-ignore]
+ tests/series/test_series.py:970: error: Too many positional arguments for "var" of "Series" [call-arg]
+ tests/series/test_series.py:970: note: Error code "call-arg" not covered by "type: ignore[misc]" comment
+ tests/series/test_series.py:970: note: "var" defined in "pandas.core.series"
+ tests/series/test_series.py:971: error: Unused "type: ignore" comment [unused-ignore]
+ tests/series/test_series.py:971: error: Too many positional arguments for "sem" of "Series" [call-arg]
+ tests/series/test_series.py:971: note: Error code "call-arg" not covered by "type: ignore[misc]" comment
+ tests/series/test_series.py:971: note: "sem" defined in "pandas.core.series"
+ tests/series/test_series.py:972: error: Unused "type: ignore" comment [unused-ignore]
+ tests/series/test_series.py:972: error: Too many positional arguments for "skew" of "Series" [call-arg]
+ tests/series/test_series.py:972: note: Error code "call-arg" not covered by "type: ignore[misc]" comment
+ tests/series/test_series.py:972: note: "skew" defined in "pandas.core.series"
+ tests/series/test_series.py:973: error: Unused "type: ignore" comment [unused-ignore]
+ tests/series/test_series.py:973: error: Too many positional arguments for "kurt" of "Series" [call-arg]
+ tests/series/test_series.py:973: note: Error code "call-arg" not covered by "type: ignore[misc]" comment
+ tests/series/test_series.py:973: note: "kurt" defined in "pandas.core.series"
cryptography (https://github.com/pyca/cryptography)
+ tests/hazmat/asn1/test_api.py:209: error: Unused "type: ignore" comment [unused-ignore]
+ tests/hazmat/asn1/test_api.py:209: error: Too many positional arguments for "Example" [call-arg]
+ tests/hazmat/asn1/test_api.py:209: note: Error code "call-arg" not covered by "type: ignore[misc]" comment
+ tests/hazmat/asn1/test_api.py:516: error: Unused "type: ignore" comment [unused-ignore]
+ tests/hazmat/asn1/test_api.py:516: error: Too many positional arguments for "Example" [call-arg]
+ tests/hazmat/asn1/test_api.py:516: note: Error code "call-arg" not covered by "type: ignore[misc]" comment
+ tests/hazmat/primitives/test_kbkdf.py:358: error: Too many positional arguments for "KBKDFHMAC" [call-arg]
+ tests/hazmat/primitives/test_kbkdf.py:358: note: "KBKDFHMAC" defined in "cryptography.hazmat.bindings._rust.openssl.kdf"
+ tests/hazmat/primitives/test_kbkdf.py:369: error: Unused "type: ignore" comment [unused-ignore]
+ tests/hazmat/primitives/test_kbkdf.py:808: error: Too many positional arguments for "KBKDFCMAC" [call-arg]
+ tests/hazmat/primitives/test_kbkdf.py:808: note: "KBKDFCMAC" defined in "cryptography.hazmat.bindings._rust.openssl.kdf"
+ tests/hazmat/primitives/test_kbkdf.py:819: error: Unused "type: ignore" comment [unused-ignore]
xarray (https://github.com/pydata/xarray)
+ xarray/tests/test_deprecation_helpers.py:18: error: Unused "type: ignore" comment [unused-ignore]
+ xarray/tests/test_deprecation_helpers.py: note: In function "test_deprecate_positional_args_warns_for_function":
+ xarray/tests/test_deprecation_helpers.py:18: error: Too many positional arguments for "f1" [call-arg]
+ xarray/tests/test_deprecation_helpers.py:18: note: Error code "call-arg" not covered by "type: ignore[misc]" comment
+ xarray/tests/test_deprecation_helpers.py: note: At top level:
+ xarray/tests/test_deprecation_helpers.py:22: error: Unused "type: ignore" comment [unused-ignore]
+ xarray/tests/test_deprecation_helpers.py: note: In function "test_deprecate_positional_args_warns_for_function":
+ xarray/tests/test_deprecation_helpers.py:22: error: Too many positional arguments for "f1" [call-arg]
+ xarray/tests/test_deprecation_helpers.py:22: note: Error code "call-arg" not covered by "type: ignore[misc]" comment
+ xarray/tests/test_deprecation_helpers.py: note: At top level:
+ xarray/tests/test_deprecation_helpers.py:26: error: Unused "type: ignore" comment [unused-ignore]
+ xarray/tests/test_deprecation_helpers.py: note: In function "test_deprecate_positional_args_warns_for_function":
+ xarray/tests/test_deprecation_helpers.py:26: error: Too many positional arguments for "f1" [call-arg]
+ xarray/tests/test_deprecation_helpers.py:26: note: Error code "call-arg" not covered by "type: ignore[misc]" comment
+ xarray/tests/test_deprecation_helpers.py: note: At top level:
+ xarray/tests/test_deprecation_helpers.py:34: error: Unused "type: ignore" comment [unused-ignore]
+ xarray/tests/test_deprecation_helpers.py: note: In function "test_deprecate_positional_args_warns_for_function":
+ xarray/tests/test_deprecation_helpers.py:34: error: Too many positional arguments for "f2" [call-arg]
+ xarray/tests/test_deprecation_helpers.py:34: note: Error code "call-arg" not covered by "type: ignore[misc]" comment
+ xarray/tests/test_deprecation_helpers.py: note: At top level:
+ xarray/tests/test_deprecation_helpers.py:42: error: Unused "type: ignore" comment [unused-ignore]
+ xarray/tests/test_deprecation_helpers.py: note: In function "test_deprecate_positional_args_warns_for_function":
+ xarray/tests/test_deprecation_helpers.py:42: error: Too many positional arguments for "f3" [call-arg]
+ xarray/tests/test_deprecation_helpers.py:42: note: Error code "call-arg" not covered by "type: ignore[misc]" comment
+ xarray/tests/test_deprecation_helpers.py: note: At top level:
+ xarray/tests/test_deprecation_helpers.py:46: error: Unused "type: ignore" comment [unused-ignore]
+ xarray/tests/test_deprecation_helpers.py: note: In function "test_deprecate_positional_args_warns_for_function":
+ xarray/tests/test_deprecation_helpers.py:46: error: Too many positional arguments for "f3" [call-arg]
+ xarray/tests/test_deprecation_helpers.py:46: note: Error code "call-arg" not covered by "type: ignore[misc]" comment
+ xarray/tests/test_deprecation_helpers.py: note: At top level:
+ xarray/tests/test_deprecation_helpers.py:60: error: Unused "type: ignore" comment [unused-ignore]
+ xarray/tests/test_deprecation_helpers.py: note: In function "test_deprecate_positional_args_warns_for_function":
+ xarray/tests/test_deprecation_helpers.py:60: error: Too many positional arguments for "f4" [call-arg]
+ xarray/tests/test_deprecation_helpers.py:60: note: Error code "call-arg" not covered by "type: ignore[misc]" comment
+ xarray/tests/test_deprecation_helpers.py: note: At top level:
+ xarray/tests/test_deprecation_helpers.py:83: error: Unused "type: ignore" comment [unused-ignore]
+ xarray/tests/test_deprecation_helpers.py: note: In function "test_deprecate_positional_args_warns_for_class":
+ xarray/tests/test_deprecation_helpers.py:83: error: Too many positional arguments for "method" of "A1" [call-arg]
+ xarray/tests/test_deprecation_helpers.py:83: note: Error code "call-arg" not covered by "type: ignore[misc]" comment
+ xarray/tests/test_deprecation_helpers.py: note: At top level:
+ xarray/tests/test_deprecation_helpers.py:87: error: Unused "type: ignore" comment [unused-ignore]
+ xarray/tests/test_deprecation_helpers.py: note: In function "test_deprecate_positional_args_warns_for_class":
+ xarray/tests/test_deprecation_helpers.py:87: error: Too many positional arguments for "method" of "A1" [call-arg]
+ xarray/tests/test_deprecation_helpers.py:87: note: Error code "call-arg" not covered by "type: ignore[misc]" comment
+ xarray/tests/test_deprecation_helpers.py: note: At top level:
+ xarray/tests/test_deprecation_helpers.py:91: error: Unused "type: ignore" comment [unused-ignore]
+ xarray/tests/test_deprecation_helpers.py: note: In function "test_deprecate_positional_args_warns_for_class":
+ xarray/tests/test_deprecation_helpers.py:91: error: Too many positional arguments for "method" of "A1" [call-arg]
+ xarray/tests/test_deprecation_helpers.py:91: note: Error code "call-arg" not covered by "type: ignore[misc]" comment
+ xarray/tests/test_deprecation_helpers.py: note: At top level:
+ xarray/tests/test_deprecation_helpers.py:100: error: Unused "type: ignore" comment [unused-ignore]
+ xarray/tests/test_deprecation_helpers.py: note: In function "test_deprecate_positional_args_warns_for_class":
+ xarray/tests/test_deprecation_helpers.py:100: error: Too many positional arguments for "method" of "A2" [call-arg]
+ xarray/tests/test_deprecation_helpers.py:100: note: Error code "call-arg" not covered by "type: ignore[misc]" comment
+ xarray/tests/test_deprecation_helpers.py: note: At top level:
+ xarray/tests/test_deprecation_helpers.py:104: error: Unused "type: ignore" comment [unused-ignore]
+ xarray/tests/test_deprecation_helpers.py: note: In function "test_deprecate_positional_args_warns_for_class":
+ xarray/tests/test_deprecation_helpers.py:104: error: Too many positional arguments for "method" of "A2" [call-arg]
+ xarray/tests/test_deprecation_helpers.py:104: note: Error code "call-arg" not covered by "type: ignore[misc]" comment
+ xarray/tests/test_deprecation_helpers.py: note: At top level:
+ xarray/tests/test_deprecation_helpers.py:113: error: Unused "type: ignore" comment [unused-ignore]
+ xarray/tests/test_deprecation_helpers.py: note: In function "test_deprecate_positional_args_warns_for_class":
+ xarray/tests/test_deprecation_helpers.py:113: error: Too many positional arguments for "method" of "A3" [call-arg]
+ xarray/tests/test_deprecation_helpers.py:113: note: Error code "call-arg" not covered by "type: ignore[misc]" comment
+ xarray/tests/test_deprecation_helpers.py: note: At top level:
+ xarray/tests/test_deprecation_helpers.py:117: error: Unused "type: ignore" comment [unused-ignore]
+ xarray/tests/test_deprecation_helpers.py: note: In function "test_deprecate_positional_args_warns_for_class":
+ xarray/tests/test_deprecation_helpers.py:117: error: Too many positional arguments for "method" of "A3" [call-arg]
+ xarray/tests/test_deprecation_helpers.py:117: note: Error code "call-arg" not covered by "type: ignore[misc]" comment
+ xarray/tests/test_deprecation_helpers.py: note: At top level:
+ xarray/tests/test_deprecation_helpers.py:132: error: Unused "type: ignore" comment [unused-ignore]
+ xarray/tests/test_deprecation_helpers.py: note: In function "test_deprecate_positional_args_warns_for_class":
+ xarray/tests/test_deprecation_helpers.py:132: error: Too many positional arguments for "method" of "A4" [call-arg]
+ xarray/tests/test_deprecation_helpers.py:132: note: Error code "call-arg" not covered by "type: ignore[misc]" comment
+ xarray/tests/test_groupby.py:2980: error: Unused "type: ignore[misc]" comment [unused-ignore]
+ xarray/tests/test_groupby.py: note: In function "test_multiple_groupers_string":
+ xarray/tests/test_groupby.py:2980: error: Too many positional arguments for "groupby" of "DataArray" [call-arg]
+ xarray/tests/test_groupby.py:2980: note: Error code "call-arg" not covered by "type: ignore[arg-type, misc]" comment
+ xarray/tests/test_groupby.py:2980: note: "groupby" defined in "xarray.core.dataarray"
+ xarray/tests/test_groupby.py: note: At top level:
|
|
There's one more thing that you can try. We support defining sub error codes by passing |
Followup to #20794
Adds the "foo" is defined in "bar" note for the
too_many_positional_argumentserror case