Closed
Description
This is possibly a BUG
I'm using returns lib that provide fully typed functions, it has a curry decorator. I'm trying to use it, but mypy
has got an error when we have a curried function with more than two args and try to create a Result container with the function.
Result.from_value(...) source code
@curry source code
Working example:
from returns.curry import curry
from returns.result import Result
@curry
def first(a: int, b: int) -> int:
...
reveal_type(
Result.from_value(first),
)
# Revealed type is 'returns.result.Result[Overload(def (a: builtins.int) -> def (b: builtins.int) -> builtins.int, def (a: builtins.int, b: builtins.int) -> builtins.int), Any]'
Nonworking example:
from returns.curry import curry
from returns.result import Result
@curry
def first(a: int, b: int, c: int) -> int:
...
reveal_type(
Result.from_value(first),
)
mypy output:
ex.py:9: note: Revealed type is 'returns.result.Result[Overload(def (a: builtins.int) -> Overload(def (b: builtins.int, c: builtins.int) -> builtins.int, def (b: builtins.int) -> def (c: builtins.int) -> builtins.int), def (a: builtins.int, b: builtins.int) -> def (c: builtins.int) -> builtins.int, def (a: builtins.int, b: builtins.int, c: builtins.int) -> builtins.int), Any]'
ex.py:9: error: Argument 1 to "from_value" of "Result" has incompatible type overloaded function; expected overloaded function
Found 1 error in 1 file (checked 1 source file)
Versions
- mypy: 0.770
- returns: 0.0.14
- Python: 3.8.2
My config file:
[mypy]
# suppress errors about unsatisfied imports
ignore_missing_imports=True
# Custom plugins
plugins =
returns.contrib.mypy.returns_plugin
# be strict
warn_return_any = True
strict_optional = True
warn_no_return = True
warn_redundant_casts = True
warn_unused_ignores = True
disallow_any_generics = True
disallow_untyped_defs = True
check_untyped_defs = True
# Temporally disabled
disallow_untyped_calls = False
Refs: dry-python/returns#410