Closed parthea closed 5 months ago
Please assign this to me. I would like to work on it.
HI @parthea , the latest version of mypy is 1.8.0 Please suggest if this version suits the code.
Yes, thanks @kitokirti for taking care of it!
Hi @parthea , in noxfile.py script, the version gets installed in the function mypy() -
session.install(MYPY_VERSION)
Please suggest what testing criteria is required here.
This change is needed to bump the mypy version
(py3816) partheniou@partheniou-vm-3:~/git/python-pubsub$ git diff
diff --git a/noxfile.py b/noxfile.py
index 3f9db8b..775e0be 100644
--- a/noxfile.py
+++ b/noxfile.py
@@ -32,7 +32,7 @@ BLACK_VERSION = "black[jupyter]==23.7.0"
ISORT_VERSION = "isort==5.11.0"
LINT_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"]
-MYPY_VERSION = "mypy==0.910"
+MYPY_VERSION = "mypy==1.8.0"
In addition, the mypy failures would need to be addressed
(py3816) partheniou@partheniou-vm-3:~/git/python-pubsub$ nox -s mypy
nox > Running session mypy
nox > Creating virtual environment (virtualenv) using python3.8 in .nox/mypy
nox > python -m pip install -e '.[all]'
nox > python -m pip install mypy==1.8.0
nox > python -m pip install types-protobuf types-setuptools
nox > python -m pip install 'google-api-core[grpc]>=2.1.1' 'google-cloud-core>=2.2.0'
nox > mypy -p google.cloud
google/cloud/pubsub_v1/subscriber/_protocol/helper_threads.py:35: error: Incompatible default for argument "max_items" (default has type "None", argument has type "int") [assignment]
google/cloud/pubsub_v1/subscriber/_protocol/helper_threads.py:35: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True
google/cloud/pubsub_v1/subscriber/_protocol/helper_threads.py:35: note: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase
google/cloud/pubsub_v1/subscriber/scheduler.py:165: error: Value of type "Iterable[Any]" is not indexable [index]
google/cloud/pubsub_v1/publisher/_sequencer/unordered_sequencer.py:110: error: Argument "batch_done_callback" has incompatible type "None"; expected "Callable[[bool], Any]" [arg-type]
google/cloud/pubsub_v1/subscriber/futures.py:107: error: Argument 1 of "result" is incompatible with supertype "Future"; supertype defines the argument type as "Optional[float]" [override]
google/cloud/pubsub_v1/subscriber/futures.py:107: note: This violates the Liskov substitution principle
google/cloud/pubsub_v1/subscriber/futures.py:107: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
google/cloud/pubsub_v1/subscriber/futures.py:107: error: Incompatible default for argument "timeout" (default has type "None", argument has type "Union[int, float]") [assignment]
google/cloud/pubsub_v1/subscriber/futures.py:107: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True
google/cloud/pubsub_v1/subscriber/futures.py:107: note: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase
google/cloud/pubsub_v1/publisher/futures.py:48: error: Argument 1 of "result" is incompatible with supertype "Future"; supertype defines the argument type as "Optional[float]" [override]
google/cloud/pubsub_v1/publisher/futures.py:48: note: This violates the Liskov substitution principle
google/cloud/pubsub_v1/publisher/futures.py:48: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
google/cloud/pubsub_v1/publisher/futures.py:48: error: Incompatible default for argument "timeout" (default has type "None", argument has type "Union[int, float]") [assignment]
google/cloud/pubsub_v1/publisher/futures.py:48: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True
google/cloud/pubsub_v1/publisher/futures.py:48: note: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase
google/cloud/pubsub_v1/publisher/_batch/thread.py:93: error: Incompatible default for argument "batch_done_callback" (default has type "None", argument has type "Callable[[bool], Any]") [assignment]
google/cloud/pubsub_v1/publisher/_batch/thread.py:93: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True
google/cloud/pubsub_v1/publisher/_batch/thread.py:93: note: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase
google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py:48: error: Module "google.rpc" has no attribute "status_pb2" [attr-defined]
google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py:270: error: Incompatible default for argument "scheduler" (default has type "None", argument has type "ThreadScheduler") [assignment]
google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py:270: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True
google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py:270: note: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase
google/cloud/pubsub_v1/subscriber/client.py:254: error: Argument "scheduler" to "StreamingPullManager" has incompatible type "Optional[ThreadScheduler]"; expected "ThreadScheduler" [arg-type]
Found 11 errors in 8 files (checked 34 source files)
nox > Command mypy -p google.cloud failed with exit code 1
nox > Session mypy failed.
These failures need to be addressed in this issue only?
Any failures that appear as a result of upgrading mypy should be addressed in the same PR that upgrades mypy.
The current version of mypy in
noxfile.py
is0.910
which is more than 2 years old. We should update to the latest version. https://github.com/googleapis/python-pubsub/blob/265f4106f499ec5d2d01a127ba192404c1836a28/noxfile.py#L35