Oh actually `mypy` outputs the same error outside ...
# welcome
l
Oh actually
mypy
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).
w
In my experience with
mypy
almost everything comes down to config and/or
__init__.py
files. Can you post your mypy config?
l
I don't have any
mypy
config since we used
pyright
so far 😕
w
Oh, ha. Can you post the
mypy
(running in isolation) output and errors
l
Copy code
> 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:
Copy code
> 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 geometry
But don't spend too much time on this @wide-midnight-78598, I could dig
mypy
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 😞
w
Okay, so this is the standard error I've run into a bunch - but what I can't recall is how to solve it. What I tend to do is check this: https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports And then either mess with the
namespace-packages
or first, make sure there is an _`__init__.py` in the chain (e.g. in
kaiko
in `geometry`_ etc). That almost always fixes everything
I can't tell if
kaiko
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) ...?
h
@lemon-oxygen-72498 did you get a chance to play with @wide-midnight-78598’s experimental pyright support?
w
l
Indeed, adding
___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).
Now I have the same
mypy
output if I run it manually, or with
pants
👍
🎉 1
@happy-kitchen-89482> yep I did try the
pyright
backend, as @wide-midnight-78598 spotted above 🙂
w
Just a heads up that the
pyright
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 stuff
l
For the record I will report on my week of experiment with
pants
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.
❀ 1
@wide-midnight-78598> yeah I have understood that. But that's okay, the company is a startup that is bootstrapping so we don't have fancy requirements right now: our codebase is small and even if we are hiring a lot, the codebase will be small by many standards in one year from now 🙂
🙂 1
From my POV it would be perfectly okay to report/ask enhancements as we grow, because you are very responsive.
w
I'm glad you suggested this one, because I've always liked
pyright
, 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 that
👍 1
l
I think it's a good objective to support `pyright`: it's a really good tool and I can only imagine its adoption growing.
Like last week, time to log off for me. See you next week! 👋
👋 1
b
For what it's worth, you can also mention to your stakeholders that Pants has excellent service providers available for contract work if needed and that you've met two of them here already! https://www.pantsbuild.org/docs/service-providers @happy-kitchen-89482 leads Toolchain and @wide-midnight-78598 leads Vicara.
l
Hey @busy-vase-39202, sure will do 👍
w
Forgot to mention: https://github.com/pantsbuild/pants/pull/17235 PR for fixing what I think this issue is @lemon-oxygen-72498 - still running through some more weird use cases though Still need to handle config and separate interpreters though
l
Yep, saw it @wide-midnight-78598, thanks for your work 👍
Also congrats to all of you 😉
👖 1
💥 4
b
Cool! Think the client would like to be listed on Who Uses Pants? It's a great chance to show they have forward-thinking team who care about code quality and developer productivity... https://www.pantsbuild.org/page/who-uses-pants
l
I think that is a bit premature since I haven't even merged the first pants PR in my client's repo 😉 My mission for them (I'm a consultant) will likely end after pants usage has been consolidated to being the main CI pipeline, so a few months from now. I will keep you posted when this happens. Then I think it will make sense to list my client (kaiko.ai) as a pants user.
h
@lemon-oxygen-72498 This is great! Were you able to use SJ’s pyright plugin successfully?
l
@happy-kitchen-89482> no because I need https://github.com/pantsbuild/pants/pull/17235 merged 🙂
w
And that's waiting on me figuring out what the correct
interpreter
command to use when I next look at it