wide-midnight-78598
04/04/2022, 2:08 PMmypy
types included with pantsbuild.pants
?
In a custom plugin, I'm running into a bunch of these... Maybe it's a Monday morning thing, but I thought I had fixed these before, but can't recall anymore:
pants-plugins/experimental/fooify/rules.py:4: error: Cannot find implementation or library stub for module named "experimental.fooify.subsystem"
pants-plugins/experimental/fooify/rules.py:5: error: Cannot find implementation or library stub for module named "experimental.fooify.target_types"
pants-plugins/experimental/fooify/rules.py:6: error: Cannot find implementation or library stub for module named "pants.core.goals.package"
pants-plugins/experimental/fooify/rules.py:7: error: Cannot find implementation or library stub for module named "pants.engine.fs"
pants-plugins/experimental/fooify/rules.py:8: error: Cannot find implementation or library stub for module named "pants.engine.rules"
pants-plugins/experimental/fooify/rules.py:9: error: Cannot find implementation or library stub for module named "pants.engine.target"
pants-plugins/experimental/fooify/rules.py:15: error: Cannot find implementation or library stub for module named "pants.engine.unions"
pants-plugins/experimental/fooify/rules.py:16: error: Cannot find implementation or library stub for module named "pants.util.logging"
wide-midnight-78598
04/04/2022, 2:08 PMfooify
plugin as my path is incorrectbitter-ability-32190
04/04/2022, 2:09 PMpyi
so yes?wide-midnight-78598
04/04/2022, 2:12 PMmypyc
plugin, but my memory is 🥔wide-midnight-78598
04/04/2022, 2:14 PMpy.typed
file... This must be a path issuewide-midnight-78598
04/04/2022, 2:40 PMbitter-ability-32190
04/04/2022, 2:41 PMpants_requirements
?bitter-ability-32190
04/04/2022, 2:41 PMwide-midnight-78598
04/04/2022, 2:41 PMmypy pants-plugins/experimental/fooify/target_types.py
fails, while other 3rd party deps in there succeed...bitter-ability-32190
04/04/2022, 2:42 PMpants
?wide-midnight-78598
04/04/2022, 2:42 PMbitter-ability-32190
04/04/2022, 2:42 PMwide-midnight-78598
04/04/2022, 2:42 PMwide-midnight-78598
04/04/2022, 2:43 PMwide-midnight-78598
04/04/2022, 2:43 PMbitter-ability-32190
04/04/2022, 2:43 PMbitter-ability-32190
04/04/2022, 2:43 PMimport pants....
wide-midnight-78598
04/04/2022, 2:44 PMbitter-ability-32190
04/04/2022, 2:44 PMmypy
assumes it's in the same environment as your code and dependenciesbitter-ability-32190
04/04/2022, 2:44 PMwide-midnight-78598
04/04/2022, 2:44 PMwide-midnight-78598
04/04/2022, 3:03 PM--namespace_packages
seems to have done the trickwide-midnight-78598
04/04/2022, 3:04 PM2.10.0
, but I don't think that's relatedhundreds-father-404
04/04/2022, 5:27 PMwide-midnight-78598
04/04/2022, 5:31 PMpantsbuild.pants
is confusing mypy? Not sure how the internals workhundreds-father-404
04/04/2022, 5:35 PMhundreds-father-404
04/04/2022, 5:36 PMwide-midnight-78598
04/04/2022, 5:41 PMdiff --git a/pants-plugins/experimental/__init__.py b/pants-plugins/experimental/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/pants.toml b/pants.toml
index 3b204b6..4eede6b 100644
--- a/pants.toml
+++ b/pants.toml
@@ -7,12 +7,17 @@ backend_packages = [
"pants.backend.plugin_development", # Adds the `pants_requirements` target type
"pants.backend.python",
"experimental.fooify",
+ "pants.backend.python.typecheck.mypy",
]
[source]
root_patterns = [
"helloworld",
+ "pants-plugins",
]
+[python]
+interpreter_constraints = [">=3.9,<3.11"]
+
[anonymous-telemetry]
enabled = false
wide-midnight-78598
04/04/2022, 5:42 PMsj@tinyrick pants-example-plugin % ./pants check ::
13:40:59.24 [INFO] Initializing scheduler...
13:40:59.42 [INFO] Scheduler initialized.
13:41:02.43 [ERROR] Completed: Typecheck using MyPy - MyPy failed (exit code 1).
pants-plugins/experimental/fooify/target_types.py:1: error: Cannot find implementation or library stub for module named "pants.engine.target"
pants-plugins/experimental/fooify/subsystem.py:1: error: Cannot find implementation or library stub for module named "pants.option.subsystem"
pants-plugins/experimental/fooify/subsystem.py:2: error: Cannot find implementation or library stub for module named "pants.engine.rules"
pants-plugins/experimental/fooify/rules.py:4: error: Cannot find implementation or library stub for module named "pants.core.goals.package"
pants-plugins/experimental/fooify/rules.py:4: note: See <https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports>
pants-plugins/experimental/fooify/rules.py:5: error: Cannot find implementation or library stub for module named "pants.engine.fs"
pants-plugins/experimental/fooify/rules.py:11: error: Cannot find implementation or library stub for module named "pants.engine.rules"
pants-plugins/experimental/fooify/rules.py:12: error: Cannot find implementation or library stub for module named "pants.engine.target"
pants-plugins/experimental/fooify/rules.py:18: error: Cannot find implementation or library stub for module named "pants.engine.unions"
pants-plugins/experimental/fooify/rules.py:19: error: Cannot find implementation or library stub for module named "pants.util.logging"
Found 9 errors in 3 files (checked 7 source files)
wide-midnight-78598
04/04/2022, 5:43 PMambitious-actor-36781
06/22/2022, 5:37 AMbitter-ability-32190
06/22/2022, 10:21 AMambitious-actor-36781
06/22/2022, 10:29 AM[tool.mypy]
namespace_packages = true
explicit_package_bases = true
in my pyproject.toml.
It was weird. Everything was being type checked correctly.
But it still errored about the stubs.ambitious-actor-36781
06/22/2022, 10:31 AMpytest
.
Have added it as an ignore, but can't work out how the pants repo does it.wide-midnight-78598
06/23/2022, 12:04 PMnamespace_packages
in a mypy.ini
hundreds-father-404
06/23/2022, 3:52 PMambitious-actor-36781
06/26/2022, 9:00 PM