You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bug Report
Depending if the cache is present or not, mypy will accuse different overload methods names for typing errors in zip/islice uses.
I've tried to reproduce de error using specific overload methods in a custom class, however mypy is consistent in this case (see extra section in the end of the issue) .
To Reproduce
main.py file:
fromitertoolsimportisliceislice([], "2")
steps to reproduce inconsistent report:
rm -rf .mypy_cache/
mypy main.py # no cache present
mypy main.py # cache is present
Expected Behavior
I would expect mypy to always report that the islice function/class doesn't have the required overload even if it doesn't have a cache already built.
$ rm -rf .mypy_cache
$ mypy main.py
main.py:2: error: No overload variant of "islice" matches argument types "list[<nothing>]", "str" [call-overload]
main.py:2: note: Possible overload variants:
main.py:2: note: def [_T] islice(self, Iterable[_T], int | None, /) -> islice[_T]
main.py:2: note: def [_T] islice(self, Iterable[_T], int | None, int | None, int | None = ..., /) -> islice[_T]
Found 1 error in 1 file (checked 1 source file)
$ mypy main.py
main.py:2: error: No overload variant of "islice" matches argument types "list[<nothing>]", "str" [call-overload]
main.py:2: note: Possible overload variants:
main.py:2: note: def [_T] islice(self, Iterable[_T], int | None, /) -> islice[_T]
main.py:2: note: def [_T] islice(self, Iterable[_T], int | None, int | None, int | None = ..., /) -> islice[_T]
Found 1 error in 1 file (checked 1 source file)
Actual Behavior
$ rm -rf .mypy_cache
$ mypy main.py
main.py:2: error: No overload variant of "islice" matches argument types "list[<nothing>]", "str" [call-overload]
main.py:2: note: Possible overload variants:
main.py:2: note: def [_T] __init__(self, Iterable[_T], int | None, /) -> islice[_T]
main.py:2: note: def [_T] __init__(self, Iterable[_T], int | None, int | None, int | None = ..., /) -> islice[_T]
Found 1 error in 1 file (checked 1 source file)
$ mypy main.py
main.py:2: error: No overload variant of "islice" matches argument types "list[<nothing>]", "str" [call-overload]
main.py:2: note: Possible overload variants:
main.py:2: note: def [_T] islice(self, Iterable[_T], int | None, /) -> islice[_T]
main.py:2: note: def [_T] islice(self, Iterable[_T], int | None, int | None, int | None = ..., /) -> islice[_T]
Found 1 error in 1 file (checked 1 source file)
Note that the first mypy execution accused the __init__ method not having the requested overload, and in the second execution it changed to islice.
Your Environment
Mypy version used: mypy 1.6.1 (compiled: yes)
Mypy command-line flags: (none)
Mypy configuration options from mypy.ini (and other config files): (none)
mypy will always accuse that the __init__ method doesn't have the overload requested:
$ rm -rf .mypy_cache
$ mypy main.py
main.py:4: error: An overloaded function outside a stub file must have an implementation [no-overload-impl]
main.py:8: error: Missing return statement [empty-body]
main.py:8: note: If the method is meant to be abstract, use @abc.abstractmethod
main.py:9: error: Missing return statement [empty-body]
main.py:9: note: If the method is meant to be abstract, use @abc.abstractmethod
main.py:10: error: No overload variant of "islice" matches argument types "list[<nothing>]", "str" [call-overload]
main.py:10: note: Possible overload variants:
main.py:10: note: def [_T] __init__(self, Iterable[_T], int | None, /) -> islice[_T]
main.py:10: note: def [_T] __init__(self, Iterable[_T], int | None, int | None, int | None = ..., /) -> islice[_T]
Found 4 errors in 1 file (checked 1 source file)
$ mypy main.py
main.py:4: error: An overloaded function outside a stub file must have an implementation [no-overload-impl]
main.py:8: error: Missing return statement [empty-body]
main.py:8: note: If the method is meant to be abstract, use @abc.abstractmethod
main.py:9: error: Missing return statement [empty-body]
main.py:9: note: If the method is meant to be abstract, use @abc.abstractmethod
main.py:10: error: No overload variant of "islice" matches argument types "list[<nothing>]", "str" [call-overload]
main.py:10: note: Possible overload variants:
main.py:10: note: def [_T] __init__(self, Iterable[_T], int | None, /) -> islice[_T]
main.py:10: note: def [_T] __init__(self, Iterable[_T], int | None, int | None, int | None = ..., /) -> islice[_T]
Found 4 errors in 1 file (checked 1 source file)
Just to add more context:
This issue can cause confusion when using mypy-baseline since it wouldn't match the mypy-baseline.txt when running in the CI without cache if the user first create the mypy-baseline.txt in his machine while having the mypy cache
giuliano-macedo
changed the title
Inconsistent error report for islice/zip "no overload match" depending if cache is present
Inconsistent error report for islice/zip "no overload match" error depending if cache is present
Oct 29, 2023
Bug Report
Depending if the cache is present or not, mypy will accuse different overload methods names for typing errors in zip/islice uses.
I've tried to reproduce de error using specific overload methods in a custom class, however mypy is consistent in this case (see extra section in the end of the issue) .
To Reproduce
main.py file:
steps to reproduce inconsistent report:
Expected Behavior
I would expect
mypy
to always report that theislice
function/class doesn't have the required overload even if it doesn't have a cache already built.Actual Behavior
Note that the first mypy execution accused the
__init__
method not having the requested overload, and in the second execution it changed toislice
.Your Environment
mypy.ini
(and other config files): (none)extra
If main.py is:
mypy will always accuse that the
__init__
method doesn't have the overload requested:another example
the same issue can happen with the
zip
method:main.py
mypy execution:
The text was updated successfully, but these errors were encountered: