Open dmaasland opened 2 years ago
Interesting, looks like a Mypy bug to me. Possibly in the attrs Mypy plugin.
Using reveal_type
, the output is identical.
Same file:
note: Revealed type is "Overload(def (value: None), def (value: builtins.str) -> datetime.datetime)"
error: Cannot determine __init__ type from converter
Different files:
note: Revealed type is "Overload(def (value: None), def (value: builtins.str) -> datetime.datetime)"
Can also confirm it's not an attr
/attrs
issue, the error is present in both scenarios.
The processing of converter
is pretty complex and I don't think I tested every scenario. My guess is this happens because of the multi-pass process that mypy uses but I haven't investigated.
Opened a PR over at Mypy for this (GitHub link right above). @euresti Any chance of a review over there?
Hello,
I'm not sure how to explain this properly but I'll do my best. Imagine a project with the following layout:
The
__init__.py
andpy.typed
files are both empty. The other two files contain the following test code:test.py
test_functions.py
This all fine and passes mypy checks:
However, if I move the functions from the
test_functions.py
file over to thetest.py
like so:test.py
mypy will fail with the following error:
test/test.py:29: error: Cannot determine __init__ type from converter
I've been scratching my head for hours about this, but I cannot seem to find a valid reason for it. I really don't want some functions in a seperate file as that will cause an even harder to solve import loop :).
Is this a bug or something I'm not properly understanding / doing wrong?
Thanks!
PS: attrs version 21.3.0, python version 3.7.12.