Skip to content
This repository was archived by the owner on Sep 5, 2023. It is now read-only.
This repository was archived by the owner on Sep 5, 2023. It is now read-only.

Add py.typed files to released packages #79

Closed
@martin1keogh

Description

@martin1keogh

Is your feature request related to a problem? Please describe.
The current package does not include the google/cloud/secretmanager/py.typed file. As such, mypy (and other type checkers) consider this package to be untyped (as specified in PEP 561):

# venv & package install
$ python3 -m venv venv && source venv/bin/activate
$ pip install google-cloud-secret-manager mypy
...
Successfully installed cachetools-4.2.1 certifi-2020.12.5 chardet-4.0.0 google-api-core-1.25.1 google-auth-1.24.0 google-cloud-secret-manager-2.2.0 googleapis-common-protos-1.52.0 grpc-google-iam-v1-0.12.3 grpcio-1.35.0 idna-2.10 libcst-0.3.16 mypy-0.800 mypy-extensions-0.4.3 proto-plus-1.13.0 protobuf-3.14.0 pyasn1-0.4.8 pyasn1-modules-0.2.8 pytz-2021.1 pyyaml-5.4.1 requests-2.25.1 rsa-4.7 six-1.15.0 typed-ast-1.4.2 typing-extensions-3.7.4.3 typing-inspect-0.6.0 urllib3-1.26.3

# no py.typed file in google/cloud/secretmanager
$ find . -iname "py.typed" 
./venv/lib/python3.8/site-packages/mypy/py.typed
./venv/lib/python3.8/site-packages/libcst/py.typed

# mypy complains about the untyped library
$ echo "from google.cloud.secretmanager import SecretManagerServiceClient" >> main.py
$ mypy main.py 
main.py:1: error: Skipping analyzing 'google.cloud.secretmanager': found module but no type hints or library stubs
main.py:1: note: See https://mypy.readthedocs.io/en/latest/running_mypy.html#missing-imports
Found 1 error in 1 file (checked 1 source file)

# adding the py.typed file in both secretmanager/ and secretmanager_v1/ , mypy doesn't complain anymore
$ touch venv/lib/python3.8/site-packages/google/cloud/secretmanager{,_v1}/py.typed
$ mypy main.py                                                                    
Success: no issues found in 1 source file

# dummy test case to check mypy finds errors
$ echo "SecretManagerServiceClient.parse_secret_path(1)" >> main.py
$ mypy main.py 
main.py:2: error: Argument 1 to "parse_secret_path" of "SecretManagerServiceClient" has incompatible type "int"; expected "str"
Found 1 error in 1 file (checked 1 source file)

Describe the solution you'd like
Have the packages on pypi contain

  • google/cloud/secretmanager/py.typed
  • google/cloud/secretmanager_v1/py.typed
  • google/cloud/secretmanager_v1beta/py.typed

Describe alternatives you've considered
Have mypy ignore those imports, but it's a bit of a shame since they're typed.

Versions
python: 3.8.5
pip: 20.0.2
google-cloud-secret-manager: 2.2.0
mypy: 0.800

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    api: secretmanagerIssues related to the googleapis/python-secret-manager API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions