Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to the latest version of mypy #1061

Open
parthea opened this issue Jan 11, 2024 · 7 comments
Open

Upgrade to the latest version of mypy #1061

parthea opened this issue Jan 11, 2024 · 7 comments
Assignees
Labels
api: pubsub Issues related to the googleapis/python-pubsub API. type: cleanup An internal cleanup or hygiene concern.

Comments

@parthea
Copy link
Contributor

parthea commented Jan 11, 2024

The current version of mypy in noxfile.py is 0.910 which is more than 2 years old. We should update to the latest version.

MYPY_VERSION = "mypy==0.910"

@parthea parthea added the type: cleanup An internal cleanup or hygiene concern. label Jan 11, 2024
@product-auto-label product-auto-label bot added the api: pubsub Issues related to the googleapis/python-pubsub API. label Jan 11, 2024
@kitokirti
Copy link

Please assign this to me. I would like to work on it.

@kitokirti
Copy link

HI @parthea , the latest version of mypy is 1.8.0
Please suggest if this version suits the code.

@parthea
Copy link
Contributor Author

parthea commented Jan 22, 2024

Yes, thanks @kitokirti for taking care of it!

https://pypi.org/project/mypy/1.8.0/

@kitokirti
Copy link

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.

@parthea
Copy link
Contributor Author

parthea commented Jan 22, 2024

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.

@parthea parthea assigned michaelpri10 and unassigned pradn Jan 22, 2024
@kitokirti
Copy link

These failures need to be addressed in this issue only?

@parthea
Copy link
Contributor Author

parthea commented Jan 23, 2024

Any failures that appear as a result of upgrading mypy should be addressed in the same PR that upgrades mypy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: pubsub Issues related to the googleapis/python-pubsub API. type: cleanup An internal cleanup or hygiene concern.
Projects
None yet
Development

No branches or pull requests

4 participants