Open plamut opened 2 years ago
I reviewed the mypy failures for the generated code and found that the warnings are specific to the customized portion of the generated code.
For example, for google/pubsub_v1/types/__init__.py:82 error: Name "google" is not defined
, the specific replacement in owlbot.py is here:
https://github.com/googleapis/python-pubsub/blob/8513f539a5dfad8ea22126706f3a4e9580df25dc/owlbot.py#L273-L288
For another error google/pubsub_v1/services/subscriber/client.py:492: error: Incompatible types in assignment (expression has type "partial[SubscriberTransport]", variable has type "Type[SubscriberTransport]")
, the specific replacement in owlbot.py is here: https://github.com/googleapis/python-pubsub/blob/8513f539a5dfad8ea22126706f3a4e9580df25dc/owlbot.py#L108-L122
I'm not sure, but isn't the py.typed file missing in google/cloud/pubsub and google/cloud/pubsub_v1?
FYI: If someone stumbles across this after struggling with mypy, you can just ignore it:
from google.cloud import pubsub_v1 # type: ignore[attr-defined]
encountering this with google-cloud-pubsub 2.18.4 -- apologies for the reopen if it's been resolved in a newer version.
500 added type annotation to the codebase, but we only checked that static type analysis passes under
pytype
. A lot of people, on the other hand, usemypy
, butmypy
currently reports 97 errors.If we want users to leverage our type annotations, we should make sure that the checks pass with
mypy
as well, and then we can also addpy.typed
file to declare the library type-checked.An additional requirement of this issue is that a new nox session named
mypy
needs to be added and enabled by default.Acceptance criteria:
mypy
is added, and it runs on every PR.542
542
mypy
checks and produces no errors. BLOCKED by https://github.com/googleapis/gapic-generator-python/issues/1092mypy
and the check runs on every PR (https://github.com/googleapis/python-pubsub/pull/551).py.typed
file (requires all above items to be completed first)