-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Improve error messages for unexpected keyword arguments in overloaded functions #20592
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
base: master
Are you sure you want to change the base?
Improve error messages for unexpected keyword arguments in overloaded functions #20592
Conversation
|
Diff from mypy_primer, showing the effect of this PR on open source code: spark (https://github.com/apache/spark)
+ python/pyspark/pandas/namespace.py:1140: error: Unexpected keyword argument "date_parser" for overloaded function "read_excel" defined on line 51 [call-overload]
- python/pyspark/pandas/namespace.py:1140: error: No overload variant of "read_excel" matches argument types "BytesIO | Any", "str | int | list[str | int] | None", "int | list[int]", "list[Any] | None", "list[int] | None", "int | str | list[int | str] | Callable[[str], bool] | None", "dict[str, str | dtype[Any] | ExtensionDtype] | None", "str | None", "dict[Any, Any] | None", "Any | None", "Any | None", "int | list[int] | None", "int | None", "Any | None", "bool", "bool", "bool | list[Any] | dict[Any, Any]", "Callable[..., Any] | None", "str | None", "str | None", "int", "dict[str, Any]" [call-overload]
- python/pyspark/pandas/namespace.py:1140: note: Possible overload variants:
- python/pyspark/pandas/namespace.py:1140: note: def [IntStrT: (int, str)] read_excel(io: str | PathLike[str] | ReadBuffer[bytes] | ExcelFile | Any | Any | Any | Any, sheet_name: list[IntStrT], *, header: int | Sequence[int] | None = ..., names: MutableSequence[Any] | ndarray[tuple[int], dtype[Any]] | tuple[Any, ...] | range | None = ..., index_col: int | Sequence[int] | str | None = ..., usecols: str | SequenceNotStr[Hashable] | range | ExtensionArray | ndarray[tuple[Any, ...], dtype[Any]] | Index[Any] | Series[Any] | Callable[[Any], bool] | None = ..., dtype: str | ExtensionDtype | str | dtype[generic[Any]] | type[complex] | type[bool] | type[object] | type[str] | Mapping[str, str | ExtensionDtype | str | dtype[generic[Any]] | type[complex] | type[bool] | type[object] | type[str]] | None = ..., engine: Literal['xlrd', 'openpyxl', 'odf', 'pyxlsb', 'calamine'] | None = ..., converters: Mapping[int | str, Callable[[Any], Any]] | None = ..., true_values: Iterable[Hashable] | None = ..., false_values: Iterable[Hashable] | None = ..., skiprows: int | Sequence[int] | Callable[[object], bool] | None = ..., nrows: int | None = ..., na_values: Sequence[str] | dict[str | int, Sequence[str]] | None = ..., keep_default_na: bool = ..., na_filter: bool = ..., verbose: bool = ..., parse_dates: bool | Sequence[int] | Sequence[Sequence[str] | Sequence[int]] | dict[str, Sequence[int] | list[str]] = ..., date_format: dict[Hashable, str] | str | None = ..., thousands: str | None = ..., decimal: str = ..., comment: str | None = ..., skipfooter: int = ..., storage_options: dict[str, Any] | None = ..., dtype_backend: Literal['pyarrow', 'numpy_nullable'] | Literal[_NoDefault.no_default] = ..., engine_kwargs: dict[str, Any] | None = ...) -> dict[IntStrT, DataFrame]
- python/pyspark/pandas/namespace.py:1140: note: def read_excel(io: str | PathLike[str] | ReadBuffer[bytes] | ExcelFile | Any | Any | Any | Any, sheet_name: None, *, header: int | Sequence[int] | None = ..., names: MutableSequence[Any] | ndarray[tuple[int], dtype[Any]] | tuple[Any, ...] | range | None = ..., index_col: int | Sequence[int] | str | None = ..., usecols: str | SequenceNotStr[Hashable] | range | ExtensionArray | ndarray[tuple[Any, ...], dtype[Any]] | Index[Any] | Series[Any] | Callable[[Any], bool] | None = ..., dtype: str | ExtensionDtype | str | dtype[generic[Any]] | type[complex] | type[bool] | type[object] | type[str] | Mapping[str, str | ExtensionDtype | str | dtype[generic[Any]] | type[complex] | type[bool] | type[object] | type[str]] | None = ..., engine: Literal['xlrd', 'openpyxl', 'odf', 'pyxlsb', 'calamine'] | None = ..., converters: Mapping[int | str, Callable[[Any], Any]] | None = ..., true_values: Iterable[Hashable] | None = ..., false_values: Iterable[Hashable] | None = ..., skiprows: int | Sequence[int] | Callable[[object], bool] | None = ..., nrows: int | None = ..., na_values: Sequence[str] | dict[str | int, Sequence[str]] | None = ..., keep_default_na: bool = ..., na_filter: bool = ..., verbose: bool = ..., parse_dates: bool | Sequence[int] | Sequence[Sequence[str] | Sequence[int]] | dict[str, Sequence[int] | list[str]] = ..., date_format: dict[Hashable, str] | str | None = ..., thousands: str | None = ..., decimal: str = ..., comment: str | None = ..., skipfooter: int = ..., storage_options: dict[str, Any] | None = ..., dtype_backend: Literal['pyarrow', 'numpy_nullable'] | Literal[_NoDefault.no_default] = ..., engine_kwargs: dict[str, Any] | None = ...) -> dict[str, DataFrame]
- python/pyspark/pandas/namespace.py:1140: note: def read_excel(io: str | PathLike[str] | ReadBuffer[bytes] | ExcelFile | Any | Any | Any | Any, sheet_name: list[int | str], *, header: int | Sequence[int] | None = ..., names: MutableSequence[Any] | ndarray[tuple[int], dtype[Any]] | tuple[Any, ...] | range | None = ..., index_col: int | Sequence[int] | str | None = ..., usecols: str | SequenceNotStr[Hashable] | range | ExtensionArray | ndarray[tuple[Any, ...], dtype[Any]] | Index[Any] | Series[Any] | Callable[[Any], bool] | None = ..., dtype: str | ExtensionDtype | str | dtype[generic[Any]] | type[complex] | type[bool] | type[object] | type[str] | Mapping[str, str | ExtensionDtype | str | dtype[generic[Any]] | type[complex] | type[bool] | type[object] | type[str]] | None = ..., engine: Literal['xlrd', 'openpyxl', 'odf', 'pyxlsb', 'calamine'] | None = ..., converters: Mapping[int | str, Callable[[Any], Any]] | None = ..., true_values: Iterable[Hashable] | None = ..., false_values: Iterable[Hashable] | None = ..., skiprows: int | Sequence[int] | Callable[[object], bool] | None = ..., nrows: int | None = ..., na_values: Sequence[str] | dict[str | int, Sequence[str]] | None = ..., keep_default_na: bool = ..., na_filter: bool = ..., verbose: bool = ..., parse_dates: bool | Sequence[int] | Sequence[Sequence[str] | Sequence[int]] | dict[str, Sequence[int] | list[str]] = ..., date_format: dict[Hashable, str] | str | None = ..., thousands: str | None = ..., decimal: str = ..., comment: str | None = ..., skipfooter: int = ..., storage_options: dict[str, Any] | None = ..., dtype_backend: Literal['pyarrow', 'numpy_nullable'] | Literal[_NoDefault.no_default] = ..., engine_kwargs: dict[str, Any] | None = ...) -> dict[int | str, DataFrame]
- python/pyspark/pandas/namespace.py:1140: note: def read_excel(io: str | PathLike[str] | ReadBuffer[bytes] | ExcelFile | Any | Any | Any | Any, sheet_name: int | str = ..., *, header: int | Sequence[int] | None = ..., names: MutableSequence[Any] | ndarray[tuple[int], dtype[Any]] | tuple[Any, ...] | range | None = ..., index_col: int | Sequence[int] | str | None = ..., usecols: str | SequenceNotStr[Hashable] | range | ExtensionArray | ndarray[tuple[Any, ...], dtype[Any]] | Index[Any] | Series[Any] | Callable[[Any], bool] | None = ..., dtype: str | ExtensionDtype | str | dtype[generic[Any]] | type[complex] | type[bool] | type[object] | type[str] | Mapping[str, str | ExtensionDtype | str | dtype[generic[Any]] | type[complex] | type[bool] | type[object] | type[str]] | None = ..., engine: Literal['xlrd', 'openpyxl', 'odf', 'pyxlsb', 'calamine'] | None = ..., converters: Mapping[int | str, Callable[[Any], Any]] | None = ..., true_values: Iterable[Hashable] | None = ..., false_values: Iterable[Hashable] | None = ..., skiprows: int | Sequence[int] | Callable[[object], bool] | None = ..., nrows: int | None = ..., na_values: Sequence[str] | dict[str | int, Sequence[str]] | None = ..., keep_default_na: bool = ..., na_filter: bool = ..., verbose: bool = ..., parse_dates: bool | Sequence[int] | Sequence[Sequence[str] | Sequence[int]] | dict[str, Sequence[int] | list[str]] = ..., date_format: dict[Hashable, str] | str | None = ..., thousands: str | None = ..., decimal: str = ..., comment: str | None = ..., skipfooter: int = ..., storage_options: dict[str, Any] | None = ..., dtype_backend: Literal['pyarrow', 'numpy_nullable'] | Literal[_NoDefault.no_default] = ..., engine_kwargs: dict[str, Any] | None = ...) -> DataFrame
prefect (https://github.com/PrefectHQ/prefect)
+ src/prefect/futures.py:222: error: Unexpected keyword argument "_sync" for overloaded function "result" of "State" defined on line 293 [call-overload]
- src/prefect/futures.py:222: error: No overload variant of "result" of "State" matches argument types "bool", "bool" [call-overload]
- src/prefect/futures.py:222: note: Possible overload variants:
- src/prefect/futures.py:222: note: def result(self, raise_on_failure: Literal[True] = ..., retry_result_failure: bool = ...) -> Any
- src/prefect/futures.py:222: note: def result(self, raise_on_failure: Literal[False] = ..., retry_result_failure: bool = ...) -> Any | Exception
- src/prefect/futures.py:222: note: def result(self, raise_on_failure: bool = ..., retry_result_failure: bool = ...) -> Any | Exception
- src/prefect/futures.py:222: note: def result(self, raise_on_failure: Literal[True] = ..., retry_result_failure: bool = ...) -> R
- src/prefect/futures.py:222: note: def result(self, raise_on_failure: Literal[False] = ..., retry_result_failure: bool = ...) -> R | Exception
- src/prefect/futures.py:222: note: def result(self, raise_on_failure: bool = ..., retry_result_failure: bool = ...) -> R | Exception
+ src/prefect/utilities/engine.py:764: error: Unexpected keyword argument "_sync" for overloaded function "result" of "State" defined on line 293 [call-overload]
- src/prefect/utilities/engine.py:764: error: No overload variant of "result" of "State" matches argument types "bool", "bool" [call-overload]
- src/prefect/utilities/engine.py:764: note: Possible overload variants:
- src/prefect/utilities/engine.py:764: note: def result(self, raise_on_failure: Literal[True] = ..., retry_result_failure: bool = ...) -> Any
- src/prefect/utilities/engine.py:764: note: def result(self, raise_on_failure: Literal[False] = ..., retry_result_failure: bool = ...) -> Any | Exception
- src/prefect/utilities/engine.py:764: note: def result(self, raise_on_failure: bool = ..., retry_result_failure: bool = ...) -> Any | Exception
- src/prefect/task_engine.py:529: error: No overload variant of "result" of "State" matches argument types "bool", "bool" [call-overload]
+ src/prefect/task_engine.py:529: error: Unexpected keyword argument "_sync" for overloaded function "result" of "State" defined on line 293 [call-overload]
- src/prefect/task_engine.py:529: note: Possible overload variants:
- src/prefect/task_engine.py:529: note: def result(self, raise_on_failure: Literal[True] = ..., retry_result_failure: bool = ...) -> R
- src/prefect/task_engine.py:529: note: def result(self, raise_on_failure: Literal[False] = ..., retry_result_failure: bool = ...) -> R | Exception
- src/prefect/task_engine.py:529: note: def result(self, raise_on_failure: bool = ..., retry_result_failure: bool = ...) -> R | Exception
scipy (https://github.com/scipy/scipy)
- scipy/sparse/linalg/tests/test_interface.py:306: error: No overload variant of "__call__" of "_GUFunc_Nin2_Nout1" matches argument types "Any", "Any", "int" [call-overload]
+ scipy/sparse/linalg/tests/test_interface.py:306: error: Unexpected keyword argument "axis" for overloaded function "__call__" of "_GUFunc_Nin2_Nout1" [call-overload]
- scipy/sparse/linalg/tests/test_interface.py:307: error: No overload variant of "__call__" of "_GUFunc_Nin2_Nout1" matches argument types "Any", "Any", "int" [call-overload]
+ scipy/sparse/linalg/tests/test_interface.py:307: error: Unexpected keyword argument "axis" for overloaded function "__call__" of "_GUFunc_Nin2_Nout1" [call-overload]
xarray (https://github.com/pydata/xarray)
+ xarray/tests/test_plot.py:1167: error: Unexpected keyword argument "start" for overloaded function "arange" defined on line 968 [call-overload]
+ xarray/tests/test_plot.py:1168: error: Unexpected keyword argument "start" for overloaded function "arange" defined on line 968 [call-overload]
- xarray/tests/test_plot.py:1167: error: No overload variant of "arange" matches argument types "int", "int", "int" [call-overload]
- xarray/tests/test_plot.py:1167: note: Possible overload variants:
- xarray/tests/test_plot.py:1167: note: def [_ArangeScalarT: integer[Any] | floating[Any] | datetime64[date | int | None] | timedelta64[timedelta | int | None]] arange(integer[Any] | floating[Any] | datetime64[date | int | None] | timedelta64[timedelta | int | None] | float, /, stop: integer[Any] | floating[Any] | datetime64[date | int | None] | timedelta64[timedelta | int | None] | float | None = ..., step: integer[Any] | floating[Any] | datetime64[date | int | None] | timedelta64[timedelta | int | None] | float | None = ..., *, dtype: type[_ArangeScalarT] | dtype[_ArangeScalarT] | _HasDType[dtype[_ArangeScalarT]] | _HasNumPyDType[dtype[_ArangeScalarT]], device: Literal['cpu'] | None = ..., like: _SupportsArrayFunc | None = ...) -> ndarray[tuple[int], dtype[_ArangeScalarT]]
- xarray/tests/test_plot.py:1167: note: def arange(int | integer[Any] | numpy.bool[builtins.bool], /, stop: int | integer[Any] | numpy.bool[builtins.bool] | None = ..., step: int | integer[Any] | numpy.bool[builtins.bool] | None = ..., *, dtype: type[int] | type[signedinteger[_32Bit | _64Bit]] | dtype[signedinteger[_32Bit | _64Bit]] | _HasDType[dtype[signedinteger[_32Bit | _64Bit]]] | _HasNumPyDType[dtype[signedinteger[_32Bit | _64Bit]]] | None = ..., device: Literal['cpu'] | None = ..., like: _SupportsArrayFunc | None = ...) -> ndarray[tuple[int], dtype[signedinteger[_32Bit | _64Bit]]]
- xarray/tests/test_plot.py:1167: note: def arange(float | floating[Any], /, stop: float | floating[Any] | integer[Any] | numpy.bool[builtins.bool] | None = ..., step: float | floating[Any] | integer[Any] | numpy.bool[builtins.bool] | None = ..., *, dtype: type[float] | type[float64] | dtype[float64] | _HasDType[dtype[float64]] | _HasNumPyDType[dtype[float64]] | None = ..., device: Literal['cpu'] | None = ..., like: _SupportsArrayFunc | None = ...) -> ndarray[tuple[int], dtype[float64 | Any]]
- xarray/tests/test_plot.py:1167: note: def arange(float | floating[Any] | integer[Any] | numpy.bool[builtins.bool], /, stop: float | floating[Any], step: float | floating[Any] | integer[Any] | numpy.bool[builtins.bool] | None = ..., *, dtype: type[float] | type[float64] | dtype[float64] | _HasDType[dtype[float64]] | _HasNumPyDType[dtype[float64]] | None = ..., device: Literal['cpu'] | None = ..., like: _SupportsArrayFunc | None = ...) -> ndarray[tuple[int], dtype[float64 | Any]]
- xarray/tests/test_plot.py:1167: note: def arange(timedelta64[timedelta | int | None], /, stop: int | timedelta64[timedelta | int | None] | integer[Any] | numpy.bool[builtins.bool] | None = ..., step: int | timedelta64[timedelta | int | None] | integer[Any] | numpy.bool[builtins.bool] | None = ..., *, dtype: type[timedelta64[timedelta | int | None]] | dtype[timedelta64[timedelta | int | None]] | _HasDType[dtype[timedelta64[timedelta | int | None]]] | _HasNumPyDType[dtype[timedelta64[timedelta | int | None]]] | None = ..., device: Literal['cpu'] | None = ..., like: _SupportsArrayFunc | None = ...) -> ndarray[tuple[int], dtype[timedelta64[Any]]]
- xarray/tests/test_plot.py:1167: note: def arange(int | timedelta64[timedelta | int | None] | integer[Any] | numpy.bool[builtins.bool], /, stop: timedelta64[timedelta | int | None], step: int | timedelta64[timedelta | int | None] | integer[Any] | numpy.bool[builtins.bool] | None = ..., *, dtype: type[timedelta64[timedelta | int | None]] | dtype[timedelta64[timedelta | int | None]] | _HasDType[dtype[timedelta64[timedelta | int | None]]] | _HasNumPyDType[dtype[timedelta64[timedelta | int | None]]] | None = ..., device: Literal['cpu'] | None = ..., like: _SupportsArrayFunc | None = ...) -> ndarray[tuple[int], dtype[timedelta64[Any]]]
- xarray/tests/test_plot.py:1167: note: def arange(datetime64[date | int | None], /, stop: datetime64[date | int | None], step: int | timedelta64[timedelta | int | None] | integer[Any] | numpy.bool[builtins.bool] | None = ..., *, dtype: type[datetime64[date | int | None]] | dtype[datetime64[date | int | None]] | _HasDType[dtype[datetime64[date | int | None]]] | _HasNumPyDType[dtype[datetime64[date | int | None]]] | None = ..., device: Literal['cpu'] | None = ..., like: _SupportsArrayFunc | None = ...) -> ndarray[tuple[int], dtype[datetime64[Any]]]
- xarray/tests/test_plot.py:1167: note: def arange(integer[Any] | floating[Any] | datetime64[date | int | None] | timedelta64[timedelta | int | None] | float, /, stop: integer[Any] | floating[Any] | datetime64[date | int | None] | timedelta64[timedelta | int | None] | float | None = ..., step: integer[Any] | floating[Any] | datetime64[date | int | None] | timedelta64[timedelta | int | None] | float | None = ..., *, dtype: type[Any] | dtype[Any] | _HasDType[dtype[Any]] | _HasNumPyDType[dtype[Any]] | tuple[Any, Any] | list[Any] | _DTypeDict | str | None = ..., device: Literal['cpu'] | None = ..., like: _SupportsArrayFunc | None = ...) -> ndarray[tuple[int], dtype[Any]]
- xarray/tests/test_plot.py:1168: error: No overload variant of "arange" matches argument types "int", "int", "int" [call-overload]
- xarray/tests/test_plot.py:1168: note: Possible overload variants:
- xarray/tests/test_plot.py:1168: note: def [_ArangeScalarT: integer[Any] | floating[Any] | datetime64[date | int | None] | timedelta64[timedelta | int | None]] arange(integer[Any] | floating[Any] | datetime64[date | int | None] | timedelta64[timedelta | int | None] | float, /, stop: integer[Any] | floating[Any] | datetime64[date | int | None] | timedelta64[timedelta | int | None] | float | None = ..., step: integer[Any] | floating[Any] | datetime64[date | int | None] | timedelta64[timedelta | int | None] | float | None = ..., *, dtype: type[_ArangeScalarT] | dtype[_ArangeScalarT] | _HasDType[dtype[_ArangeScalarT]] | _HasNumPyDType[dtype[_ArangeScalarT]], device: Literal['cpu'] | None = ..., like: _SupportsArrayFunc | None = ...) -> ndarray[tuple[int], dtype[_ArangeScalarT]]
- xarray/tests/test_plot.py:1168: note: def arange(int | integer[Any] | numpy.bool[builtins.bool], /, stop: int | integer[Any] | numpy.bool[builtins.bool] | None = ..., step: int | integer[Any] | numpy.bool[builtins.bool] | None = ..., *, dtype: type[int] | type[signedinteger[_32Bit | _64Bit]] | dtype[signedinteger[_32Bit | _64Bit]] | _HasDType[dtype[signedinteger[_32Bit | _64Bit]]] | _HasNumPyDType[dtype[signedinteger[_32Bit | _64Bit]]] | None = ..., device: Literal['cpu'] | None = ..., like: _SupportsArrayFunc | None = ...) -> ndarray[tuple[int], dtype[signedinteger[_32Bit | _64Bit]]]
- xarray/tests/test_plot.py:1168: note: def arange(float | floating[Any], /, stop: float | floating[Any] | integer[Any] | numpy.bool[builtins.bool] | None = ..., step: float | floating[Any] | integer[Any] | numpy.bool[builtins.bool] | None = ..., *, dtype: type[float] | type[float64] | dtype[float64] | _HasDType[dtype[float64]] | _HasNumPyDType[dtype[float64]] | None = ..., device: Literal['cpu'] | None = ..., like: _SupportsArrayFunc | None = ...) -> ndarray[tuple[int], dtype[float64 | Any]]
- xarray/tests/test_plot.py:1168: note: def arange(float | floating[Any] | integer[Any] | numpy.bool[builtins.bool], /, stop: float | floating[Any], step: float | floating[Any] | integer[Any] | numpy.bool[builtins.bool] | None = ..., *, dtype: type[float] | type[float64] | dtype[float64] | _HasDType[dtype[float64]] | _HasNumPyDType[dtype[float64]] | None = ..., device: Literal['cpu'] | None = ..., like: _SupportsArrayFunc | None = ...) -> ndarray[tuple[int], dtype[float64 | Any]]
- xarray/tests/test_plot.py:1168: note: def arange(timedelta64[timedelta | int | None], /, stop: int | timedelta64[timedelta | int | None] | integer[Any] | numpy.bool[builtins.bool] | None = ..., step: int | timedelta64[timedelta | int | None] | integer[Any] | numpy.bool[builtins.bool] | None = ..., *, dtype: type[timedelta64[timedelta | int | None]] | dtype[timedelta64[timedelta | int | None]] | _HasDType[dtype[timedelta64[timedelta | int | None]]] | _HasNumPyDType[dtype[timedelta64[timedelta | int | None]]] | None = ..., device: Literal['cpu'] | None = ..., like: _SupportsArrayFunc | None = ...) -> ndarray[tuple[int], dtype[timedelta64[Any]]]
- xarray/tests/test_plot.py:1168: note: def arange(int | timedelta64[timedelta | int | None] | integer[Any] | numpy.bool[builtins.bool], /, stop: timedelta64[timedelta | int | None], step: int | timedelta64[timedelta | int | None] | integer[Any] | numpy.bool[builtins.bool] | None = ..., *, dtype: type[timedelta64[timedelta | int | None]] | dtype[timedelta64[timedelta | int | None]] | _HasDType[dtype[timedelta64[timedelta | int | None]]] | _HasNumPyDType[dtype[timedelta64[timedelta | int | None]]] | None = ..., device: Literal['cpu'] | None = ..., like: _SupportsArrayFunc | None = ...) -> ndarray[tuple[int], dtype[timedelta64[Any]]]
- xarray/tests/test_plot.py:1168: note: def arange(datetime64[date | int | None], /, stop: datetime64[date | int | None], step: int | timedelta64[timedelta | int | None] | integer[Any] | numpy.bool[builtins.bool] | None = ..., *, dtype: type[datetime64[date | int | None]] | dtype[datetime64[date | int | None]] | _HasDType[dtype[datetime64[date | int | None]]] | _HasNumPyDType[dtype[datetime64[date | int | None]]] | None = ..., device: Literal['cpu'] | None = ..., like: _SupportsArrayFunc | None = ...) -> ndarray[tuple[int], dtype[datetime64[Any]]]
- xarray/tests/test_plot.py:1168: note: def arange(integer[Any] | floating[Any] | datetime64[date | int | None] | timedelta64[timedelta | int | None] | float, /, stop: integer[Any] | floating[Any] | datetime64[date | int | None] | timedelta64[timedelta | int | None] | float | None = ..., step: integer[Any] | floating[Any] | datetime64[date | int | None] | timedelta64[timedelta | int | None] | float | None = ..., *, dtype: type[Any] | dtype[Any] | _HasDType[dtype[Any]] | _HasNumPyDType[dtype[Any]] | tuple[Any, Any] | list[Any] | _DTypeDict | str | None = ..., device: Literal['cpu'] | None = ..., like: _SupportsArrayFunc | None = ...) -> ndarray[tuple[int], dtype[Any]]
|
| def f(foobar: Union[int, str]) -> None: | ||
| pass | ||
|
|
||
| f(fobar=1) # E: Unexpected keyword argument "fobar" for overloaded function "f" defined on line 4; did you mean "foobar"? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't report the line number here. It could be useful to report it, but we generally use a note, since the function could be in a different file so line number by itself isn't sufficient.
| pass | ||
|
|
||
| f(fobar=1) # E: Unexpected keyword argument "fobar" for overloaded function "f" defined on line 4; did you mean "foobar"? | ||
| f(random=[1,2,3]) # E: Unexpected keyword argument "random" for overloaded function "f" \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additional test ideas:
- Test multiple invalid keyword arguments
- Test both invalid keyword argument and incompatible positional argument
- Test both valid an invalid keyword arguments in the same call
This PR improves error messages when calling overloaded functions with unexpected keyword arguments, making it easier to identify and fix typos.
Changes
best_matchesfuzzy matching)