cool-easter-32542
12/04/2023, 3:26 AMpants check :: failed with a lot of error messages when mypy is configured with a separate lock file.
Pants version
2.17.0 and 2.18.0
OS
Linux 5.4.0-167-generic 184-Ubuntu SMP
Additional info
Having an issue with pants check :: type checking when mypy is configured with separate lock file. As shown in the configuration below, the resolves are separated depending on which tool is running.
# pants.toml
[python]
interpreter_constraints = ["CPython==3.9.*"]
default_resolve = "python-default"
enable_resolves = true
[python.resolves]
flake8 = "3rdparty/python/flake8.lock"
pytest = "3rdparty/python/pytest.lock"
mypy = "3rdparty/python/mypy.lock"
python-default = "3rdparty/python/default.lock"
[flake8]
install_from_resolve = "flake8"
requirements = ["//3rdparty:flake8"]
[pytest]
install_from_resolve = "pytest"
requirements = ["//3rdparty:pytest"]
[mypy]
install_from_resolve = "mypy"
requirements = ["//3rdparty:mypy"]
[python-protobuf]
mypy_plugin = true
infer_runtime_dependency = false
# 3rdparty/BUILD
... ...
... ...
python_requirements(
name="mypy",
source="requirements-mypy.txt",
resolve="mypy",
)
However, All works, except mypy. Seems mypy doesn't work out the resolves using the specified lock files. When I run pants check :: command, the output shows a lot type checking errors
14:48:09.10 [ERROR] Completed: Typecheck using MyPy - mypy - mypy failed (exit code 1).
service_pb2.pyi:7: error: Library stubs not installed for "google.protobuf.descriptor" [import-untyped]
service_pb2.pyi:7: error: Library stubs not installed for "google.protobuf" [import-untyped]
service_pb2.pyi:7: error: Skipping analyzing "google": module is installed, but missing library stubs or py.typed marker [import-untyped]
service_pb2.pyi:8: error: Library stubs not installed for "google.protobuf.internal.containers" [import-untyped]
service_pb2.pyi:8: error: Library stubs not installed for "google.protobuf.internal" [import-untyped]
service_pb2.pyi:9: error: Library stubs not installed for "google.protobuf.internal.enum_type_wrapper" [import-untyped]
service_pb2.pyi:10: error: Library stubs not installed for "google.protobuf.message" [import-untyped]
tools/utils.py:3: error: Library stubs not installed for "colorama" [import-untyped]
service_pb2_grpc.pyi:10: error: Name "grpc.Channel" is not defined [name-defined]
service_pb2_grpc.pyi:11: error: Name "grpc.UnaryUnaryMultiCallable" is not defined [name-defined]
service_pb2_grpc.pyi:21: error: Name "grpc.ServicerContext" is not defined [name-defined]
service_pb2_grpc.pyi:24: error: Name "grpc.Server" is not defined [name-defined]
client.py:4: error: Library stubs not installed for "colorama" [import-untyped]
client.py:4: note: Hint: "python3 -m pip install types-colorama"
client.py:37: error: Module has no attribute "insecure_channel" [attr-defined]
scripts/request_ext.py:4: error: Library stubs not installed for "requests" [import-untyped]
scripts/request_ext.py:5: error: Library stubs not installed for "requests.exceptions" [import-untyped]
unit/types.py:14: error: Library stubs not installed for "dateutil" [import-untyped]
system/account_date.py:3: error: Library stubs not installed for "dateutil.relativedelta" [import-untyped]
schedule.py:4: error: Library stubs not installed for "dateutil.relativedelta" [import-untyped]
schedule.py:4: note: Hint: "python3 -m pip install types-python-dateutil"
... ...
... ...
The suggested workaround (#19757) for the problem is to use the default resolve for mypy. It does work. However, not sure if it's the proper way of solving the problem.
pantsbuild/pants