Hi, I'm trying to curry a class constructor, but mypy complains
# main.py from returns.curry import curry @curry class Person: def __init__(self, name: str, age: int): self.name = name self.age = age Person("bob")(33)
$ mypy main.py main.py:10: error: Missing positional argument "age" in call to "Person" main.py:10: error: "Person" not callable Found 2 errors in 1 file (checked 1 source file)
Here is my mypy.ini file:
[mypy] plugins = returns.contrib.mypy.returns_plugin
mypy should not report any error
python version: 3.10.4
python
returns version: 0.19.0
returns
mypy version: 0.971
mypy
hypothesis version (if any): not installed
hypothesis
pytest version (if any): not installed
pytest
This is a known issue.
Thank you for this piece of information :)
Try this:
returns/typesafety/test_curry/test_curry/test_curry_arguments.yml
Line 75 in 964479d
mypy doesn't complain about that:
from returns.curry import curry class Test(object): @curry def __init__(self, arg: int, other: str) -> None: ... Test(1)
But does complain about that:
Test(1)("")
$ mypy main.py main.py:9: error: "Test" not callable Found 1 error in 1 file (checked 1 source file)
In both cases, python doesn't seem to like the curry on __init__:
__init__
$ python main.py Traceback (most recent call last): File "/Users/jul/dev/bug-curry/main.py", line 9, in <module> Test(1) TypeError: __init__() should return None, not 'function'
Activity
sobolevn commentedon Sep 2, 2022
This is a known issue.
swoutch commentedon Sep 2, 2022
Thank you for this piece of information :)
sobolevn commentedon Sep 2, 2022
Try this:
returns/typesafety/test_curry/test_curry/test_curry_arguments.yml
Line 75 in 964479d
swoutch commentedon Sep 2, 2022
mypy doesn't complain about that:
But does complain about that:
In both cases, python doesn't seem to like the curry on
__init__: