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 3 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.
This comment has been minimized.
This comment has been minimized.
|
There's one more thing that you can try. We support defining sub error codes by passing |
|
Diff from mypy_primer, showing the effect of this PR on open source code: mypy (https://github.com/python/mypy)
+ mypy/test/testtypes.py:239: error: Unused "type: ignore" comment, use narrower [call-arg] instead of [misc] code [unused-ignore]
urllib3 (https://github.com/urllib3/urllib3)
+ test/with_dummyserver/test_poolmanager.py:659: error: Unused "type: ignore" comment, use narrower [call-arg] instead of [misc] code [unused-ignore]
pandas-stubs (https://github.com/pandas-dev/pandas-stubs)
+ tests/test_string_accessors.py:226: error: Unused "type: ignore" comment, use narrower [call-arg] instead of [misc] code [unused-ignore]
+ tests/test_string_accessors.py:290: error: Unused "type: ignore" comment, use narrower [call-arg] instead of [misc] code [unused-ignore]
+ tests/series/test_series.py:177: error: Unused "type: ignore" comment, use narrower [call-arg] instead of [misc] code [unused-ignore]
+ tests/series/test_series.py:186: error: Unused "type: ignore" comment, use narrower [call-arg] instead of [misc] code [unused-ignore]
+ tests/series/test_series.py:491: error: Unused "type: ignore" comment, use narrower [call-arg] instead of [misc] code [unused-ignore]
+ tests/series/test_series.py:552: error: Unused "type: ignore" comment, use narrower [call-arg] instead of [misc] code [unused-ignore]
+ tests/series/test_series.py:567: error: Unused "type: ignore" comment, use narrower [call-arg] instead of [misc] code [unused-ignore]
+ tests/series/test_series.py:971: error: Unused "type: ignore" comment, use narrower [call-arg] instead of [misc] code [unused-ignore]
+ tests/series/test_series.py:972: error: Unused "type: ignore" comment, use narrower [call-arg] instead of [misc] code [unused-ignore]
+ tests/series/test_series.py:973: error: Unused "type: ignore" comment, use narrower [call-arg] instead of [misc] code [unused-ignore]
+ tests/series/test_series.py:974: error: Unused "type: ignore" comment, use narrower [call-arg] instead of [misc] code [unused-ignore]
+ tests/series/test_series.py:975: error: Unused "type: ignore" comment, use narrower [call-arg] instead of [misc] code [unused-ignore]
+ tests/series/test_series.py:976: error: Unused "type: ignore" comment, use narrower [call-arg] instead of [misc] code [unused-ignore]
+ tests/series/test_series.py:977: error: Unused "type: ignore" comment, use narrower [call-arg] instead of [misc] code [unused-ignore]
cryptography (https://github.com/pyca/cryptography)
+ tests/hazmat/asn1/test_api.py:259: error: Unused "type: ignore" comment, use narrower [call-arg] instead of [misc] code [unused-ignore]
+ tests/hazmat/asn1/test_api.py:574: error: Unused "type: ignore" comment, use narrower [call-arg] instead of [misc] code [unused-ignore]
+ tests/hazmat/primitives/test_kbkdf.py:369: error: Unused "type: ignore" comment, use narrower [call-arg] instead of [misc] code [unused-ignore]
+ tests/hazmat/primitives/test_kbkdf.py:819: error: Unused "type: ignore" comment, use narrower [call-arg] instead of [misc] code [unused-ignore]
xarray (https://github.com/pydata/xarray)
+ xarray/tests/test_deprecation_helpers.py:18: error: Unused "type: ignore" comment, use narrower [call-arg] instead of [misc] code [unused-ignore]
+ xarray/tests/test_deprecation_helpers.py:22: error: Unused "type: ignore" comment, use narrower [call-arg] instead of [misc] code [unused-ignore]
+ xarray/tests/test_deprecation_helpers.py:26: error: Unused "type: ignore" comment, use narrower [call-arg] instead of [misc] code [unused-ignore]
+ xarray/tests/test_deprecation_helpers.py:34: error: Unused "type: ignore" comment, use narrower [call-arg] instead of [misc] code [unused-ignore]
+ xarray/tests/test_deprecation_helpers.py:42: error: Unused "type: ignore" comment, use narrower [call-arg] instead of [misc] code [unused-ignore]
+ xarray/tests/test_deprecation_helpers.py:46: error: Unused "type: ignore" comment, use narrower [call-arg] instead of [misc] code [unused-ignore]
+ xarray/tests/test_deprecation_helpers.py:60: error: Unused "type: ignore" comment, use narrower [call-arg] instead of [misc] code [unused-ignore]
+ xarray/tests/test_deprecation_helpers.py:83: error: Unused "type: ignore" comment, use narrower [call-arg] instead of [misc] code [unused-ignore]
+ xarray/tests/test_deprecation_helpers.py:87: error: Unused "type: ignore" comment, use narrower [call-arg] instead of [misc] code [unused-ignore]
+ xarray/tests/test_deprecation_helpers.py:91: error: Unused "type: ignore" comment, use narrower [call-arg] instead of [misc] code [unused-ignore]
+ xarray/tests/test_deprecation_helpers.py:100: error: Unused "type: ignore" comment, use narrower [call-arg] instead of [misc] code [unused-ignore]
+ xarray/tests/test_deprecation_helpers.py:104: error: Unused "type: ignore" comment, use narrower [call-arg] instead of [misc] code [unused-ignore]
+ xarray/tests/test_deprecation_helpers.py:113: error: Unused "type: ignore" comment, use narrower [call-arg] instead of [misc] code [unused-ignore]
+ xarray/tests/test_deprecation_helpers.py:117: error: Unused "type: ignore" comment, use narrower [call-arg] instead of [misc] code [unused-ignore]
+ xarray/tests/test_deprecation_helpers.py:132: error: Unused "type: ignore" comment, use narrower [call-arg] instead of [misc] code [unused-ignore]
+ xarray/tests/test_groupby.py:2980: error: Unused "type: ignore[misc]" comment, use narrower [call-arg] instead of [misc] code [unused-ignore]
|
|
@ilevkivskyi @JukkaL is this an acceptable error in the primer? it only occurs when they use |
|
Yes, the primer looks acceptable. Can you look at the self check CI failures? |
Followup to #20794
Adds the "foo" is defined in "bar" note for the
too_many_positional_argumentserror case