pytest-mypy-testing icon indicating copy to clipboard operation
pytest-mypy-testing copied to clipboard

Support for call-overload errors

Open ollij93 opened this issue 2 years ago • 0 comments

For a "[call-overload]" error mypy raises an error and multiple note messages. Since we can't test for multiple messages on the same line its currently not possible to successfully test for call-overload errors.

Example:

field: str = dataclasses.field(default="A", default_factory=lambda: "B") # E: [call-overload]

The error message is being tested for correctly, but there are multiple notes which cause the test to fail:

  A: note: Possible overload variants:
  A: note: def [_T] field(*, default: _T, init: bool = ..., repr: bool = ..., hash: bool | None = ..., compare: bool = ..., metadata: Mapping[Any, Any] | None = ..., kw_only: bool = ...) -> _T
  A: note: def [_T] field(*, default_factory: Callable[[], _T], init: bool = ..., repr: bool = ..., hash: bool | None = ..., compare: bool = ..., metadata: Mapping[Any, Any] | None = ..., kw_only: bool = ...) -> _T
  A: note: def field(*, init: bool = ..., repr: bool = ..., hash: bool | None = ..., compare: bool = ..., metadata: Mapping[Any, Any] | None = ..., kw_only: bool = ...) -> Any

ollij93 avatar Sep 01 '23 11:09 ollij93