lemon-oxygen-72498
10/14/2022, 8:15 AMmypy outputs the same error outside pants. Hum so likely not a pants issue but an unexpected pyright <> mypy mismatch (we use pyright in production, I have been trying mypy for pants evaluation).wide-midnight-78598
10/14/2022, 1:03 PMmypy almost everything comes down to config and/or __init__.py files. Can you post your mypy config?lemon-oxygen-72498
10/14/2022, 2:19 PMmypy config since we used pyright so far ðwide-midnight-78598
10/14/2022, 2:44 PMmypy (running in isolation) output and errorslemon-oxygen-72498
10/14/2022, 2:48 PM> mypy $(git ls-files "*.py")
kaiko/geometry/__init__.py:1: error: Cannot find implementation or library stub for module named "kaiko.geometry.geometry_box"
kaiko/geometry/__init__.py:1: note: See <https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports>
kaiko/geometry/__init__.py:2: error: Cannot find implementation or library stub for module named "kaiko.geometry.geometry_point"
kaiko/geometry/__init__.py:3: error: Cannot find implementation or library stub for module named "kaiko.geometry.geometry_size"
kaiko/geometry/geometry_size.py:8: error: First argument to namedtuple() should be "_SizeInt", not "Point"
kaiko/geometry/geometry_point.py:8: error: First argument to namedtuple() should be "_PointInt", not "Point"
kaiko/geometry/geometry_point.py:9: error: First argument to namedtuple() should be "_PointFloat", not "Point"
kaiko/geometry/geometry_box.py:8: error: Cannot find implementation or library stub for module named "kaiko.geometry"
kaiko/geometry/geometry_box.py:180: error: Argument 1 of "__eq__" is incompatible with supertype "object"; supertype defines the argument type as "object"
kaiko/geometry/geometry_box.py:180: note: This violates the Liskov substitution principle
kaiko/geometry/geometry_box.py:180: note: See <https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides>
kaiko/geometry/geometry_box.py:180: note: It is recommended for "__eq__" to work with arbitrary objects, for example:
kaiko/geometry/geometry_box.py:180: note: def __eq__(self, other: object) -> bool:
kaiko/geometry/geometry_box.py:180: note: if not isinstance(other, Box):
kaiko/geometry/geometry_box.py:180: note: return NotImplemented
kaiko/geometry/geometry_box.py:180: note: return <logic to compare two Box instances>
tests/test_point.py:6: error: Cannot find implementation or library stub for module named "kaiko"
tests/test_box.py:8: error: Cannot find implementation or library stub for module named "kaiko"
Found 10 errors in 6 files (checked 7 source files)
Imports are done as follows:
> git --no-pager grep 'import.*kaiko\|kaiko.*import'
kaiko/geometry/__init__.py:from kaiko.geometry.geometry_box import Box
kaiko/geometry/__init__.py:from kaiko.geometry.geometry_point import PointFloat, PointInt
kaiko/geometry/__init__.py:from kaiko.geometry.geometry_size import SizeInt
kaiko/geometry/geometry_box.py:from kaiko.geometry import geometry_point, geometry_size
tests/test_box.py:from kaiko import geometry
tests/test_point.py:from kaiko import geometrylemon-oxygen-72498
10/14/2022, 2:49 PMmypy configuration myself I suppose. It's likely something silly since pyright $(git ls-files "*.py") runs fine. I just didn't have the time to do it myself yet ðwide-midnight-78598
10/14/2022, 2:57 PMnamespace-packages or first, make sure there is an _`__init__.py` in the chain (e.g. in kaiko in `geometry`_ etc). That almost always fixes everythingwide-midnight-78598
10/14/2022, 3:08 PMkaiko has an init.py, but if it's not supposed to - then I think it would need to be classified as a namespace-package (https://mypy.readthedocs.io/en/stable/command_line.html#cmdoption-mypy-namespace-packages) ...?happy-kitchen-89482
10/14/2022, 3:21 PMwide-midnight-78598
10/14/2022, 3:25 PMlemon-oxygen-72498
10/14/2022, 3:30 PM___init___.py to kaiko made mypy found the imports ð I suppose pyright honors pyproject.toml more thoroughly than mypy (because kaiko is declared as a package there with the packages keyword).lemon-oxygen-72498
10/14/2022, 3:30 PMmypy output if I run it manually, or with pants ðlemon-oxygen-72498
10/14/2022, 3:31 PMpyright backend, as @wide-midnight-78598 spotted above ðwide-midnight-78598
10/14/2022, 3:33 PMpyright backend is suuuuper naive right now - doesn't grab CoarsenedTargets, doesn't partition the code, etc - it currently just says "what did you pass in, let me pyright it"
The configuration, dep inference, and other stuff will come down the line - I was hoping to get a few hours this weekend to do the dep inference + partitioning stufflemon-oxygen-72498
10/14/2022, 3:33 PMpants to my company on Monday ð
Big kudos to the team's responsiveness here and on GitHub. For example I think it would have been a blocker for the deciders not to have pyright support in pants. So your responsiveness this week will likely make a difference in the appreciation of pants from the stakholders POV.lemon-oxygen-72498
10/14/2022, 3:35 PMlemon-oxygen-72498
10/14/2022, 3:35 PMwide-midnight-78598
10/14/2022, 3:37 PMpyright, but never used it outside the IDE - so, I'm happy to be able to use it in my own projects now ð
Definitely enhancements coming once I get rolling with thatlemon-oxygen-72498
10/14/2022, 3:39 PMlemon-oxygen-72498
10/14/2022, 3:47 PMbusy-vase-39202
10/14/2022, 4:26 PMlemon-oxygen-72498
10/14/2022, 6:08 PMwide-midnight-78598
10/17/2022, 4:50 PMlemon-oxygen-72498
10/18/2022, 6:50 AMlemon-oxygen-72498
10/18/2022, 6:51 AMbusy-vase-39202
10/18/2022, 11:14 PMlemon-oxygen-72498
10/19/2022, 7:36 AMhappy-kitchen-89482
10/19/2022, 2:11 PMlemon-oxygen-72498
10/19/2022, 2:12 PMwide-midnight-78598
10/19/2022, 2:13 PMinterpreter command to use when I next look at it