Name | google-api-python-client-stubs JSON |
Version |
1.29.0
JSON |
| download |
home_page | None |
Summary | Type stubs for google-api-python-client |
upload_time | 2025-01-24 20:16:49 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.7 |
license | None |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Type stubs for google-api-python-client
[](https://badge.fury.io/py/google-api-python-client-stubs)
This package provides type stubs for the [google-api-python-client](https://github.com/googleapis/google-api-python-client) library.
It allows you to type check usage of the library with e.g. [mypy](http://mypy-lang.org/) and will also improve autocomplete in many editors.
**This is in no way affiliated with Google.**
The stubs were generated automatically based on Google's [Discovery Documents](https://developers.google.com/discovery/v1/reference/apis), that are bundled with google-api-python-client as of v2.
If you find incorrect annotations, please create an issue.
Releases can be somewhat infrequent. If you need a new release, create an issue and I'll probably get around to it faster.
## Installation
```shell script
$ pip install google-api-python-client-stubs
```
The stubs should be automatically picked up by your editor or typechecker.
## Caveats
### Explicit annotations
The `google-api-python-client-stubs` is quite dynamic.
All resources are just instances of a single class with dynamically attached methods
and the requests and responses are just dictionaries. The way this is annotated is with
classes and [TypedDicts](https://docs.python.org/3/library/typing.html#typing.TypedDict)
that don't exist in the actual library, only in the stub files. This means you *cannot* use any of these types at runtime, it *will* cause your code to crash.
If you rely solely on type inference, this is not an issue, but as soon as you want to explicitly
annotate a variable, argument or return type in your code with one of these types, you must follow these rules:
1. Either put `from __future__ import annotations` at the top of your file or surround the annotations with quotes.
This ensures that Python doesn't attempt to evaluate the types at runtime.
Note that the import is only supported in Python 3.7 and above.
2. Only import the types inside an `if typing.TYPE_CHECKING` block. This ensures that the imports are only evaluated during
type checking, not at runtime.
Any type not available at runtime is located under the `googleapiclient._apis` package, with a subpackage for the API and a subpackage for the API version.
For example, the return type of `build("sheets", "v4")`, `SheetsResource`, should be imported from `googleapiclient._apis.sheets.v4`. Nested resources have a nested class structure, e.g. the return type of `build("sheets", "v4").spreadsheets().values()` is `SheetsResource.SpreadsheetsResource.ValuesResource`.
If autocompleting import paths doesn't work you can find the correct path by using Mypy's [reveal_type](https://mypy.readthedocs.io/en/stable/common_issues.html#reveal-type)
on the thing you want to explicitly annotate. For `TypedDict`s this will also give you useful info about the structure of the dictionary.
If you use Pyright/Pylance, you'll get a [reportMissingModuleSource](https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportMissingModuleSource) error at the import site, which indicates that the stub file doesn't have a corresponding source file. As long as the import only occurs during typechecking, this can be safely ignored. Autocomplete and typechecking will still work.
Note that since the types don't exist at runtime, they're not compatible with libraries that evaluate annotations at runtime. For example, you can't use them to annotate a field in a Pydantic model.
### Performance
The stubs contain a separate overload of `googleapiclient.discovery.build` for each service and version (see `discovery.pyi`).
This can lead to slow type inference for this function. Mypy will generally be pretty fast after the first run,
but you might experience slow autocomplete in your editor. If you're experiencing this problem you can bypass type inference with explicit annotations,
e.g. `sheets_service: SheetsResource = build("sheets", "v4")` instead of `sheets_service = build("sheets", "v4")`.
Note the caveats to this approach in the previous section.
### Recursive types
The stubs previously didn't include recursive type definitions due to a lack of type checker support, but this is now included. Note that if you're using Mypy, v0.990 or higher is required for this to work.
### Stubs for non-API-specific parts
There are detailed stubs for the API services, but other parts of the library have only been annotated with [stubgen](https://mypy.readthedocs.io/en/stable/stubgen.html),
so they're mostly typed as `Any`. I believe these parts are mostly used internally by the library itself,
so for most users this should be fine. Contributions to improve these stubs are welcome, though.
Raw data
{
"_id": null,
"home_page": null,
"name": "google-api-python-client-stubs",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": null,
"author": null,
"author_email": "Henrik Bru\u00e5sdal <henrik.bruasdal@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/d8/95/10777e7b965319ad1ac3b8379747040e9002827be18587b313aec0c47fc8/google_api_python_client_stubs-1.29.0.tar.gz",
"platform": null,
"description": "# Type stubs for google-api-python-client\n\n[](https://badge.fury.io/py/google-api-python-client-stubs)\n\nThis package provides type stubs for the [google-api-python-client](https://github.com/googleapis/google-api-python-client) library. \nIt allows you to type check usage of the library with e.g. [mypy](http://mypy-lang.org/) and will also improve autocomplete in many editors.\n\n**This is in no way affiliated with Google.**\n\nThe stubs were generated automatically based on Google's [Discovery Documents](https://developers.google.com/discovery/v1/reference/apis), that are bundled with google-api-python-client as of v2.\n\nIf you find incorrect annotations, please create an issue.\n\nReleases can be somewhat infrequent. If you need a new release, create an issue and I'll probably get around to it faster.\n\n## Installation\n\n```shell script\n$ pip install google-api-python-client-stubs\n```\n\nThe stubs should be automatically picked up by your editor or typechecker.\n\n## Caveats\n\n### Explicit annotations\nThe `google-api-python-client-stubs` is quite dynamic. \nAll resources are just instances of a single class with dynamically attached methods\nand the requests and responses are just dictionaries. The way this is annotated is with\nclasses and [TypedDicts](https://docs.python.org/3/library/typing.html#typing.TypedDict)\nthat don't exist in the actual library, only in the stub files. This means you *cannot* use any of these types at runtime, it *will* cause your code to crash.\nIf you rely solely on type inference, this is not an issue, but as soon as you want to explicitly\nannotate a variable, argument or return type in your code with one of these types, you must follow these rules:\n1. Either put `from __future__ import annotations` at the top of your file or surround the annotations with quotes. \nThis ensures that Python doesn't attempt to evaluate the types at runtime. \nNote that the import is only supported in Python 3.7 and above.\n2. Only import the types inside an `if typing.TYPE_CHECKING` block. This ensures that the imports are only evaluated during\ntype checking, not at runtime.\n\nAny type not available at runtime is located under the `googleapiclient._apis` package, with a subpackage for the API and a subpackage for the API version.\nFor example, the return type of `build(\"sheets\", \"v4\")`, `SheetsResource`, should be imported from `googleapiclient._apis.sheets.v4`. Nested resources have a nested class structure, e.g. the return type of `build(\"sheets\", \"v4\").spreadsheets().values()` is `SheetsResource.SpreadsheetsResource.ValuesResource`.\nIf autocompleting import paths doesn't work you can find the correct path by using Mypy's [reveal_type](https://mypy.readthedocs.io/en/stable/common_issues.html#reveal-type)\non the thing you want to explicitly annotate. For `TypedDict`s this will also give you useful info about the structure of the dictionary.\n\nIf you use Pyright/Pylance, you'll get a [reportMissingModuleSource](https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportMissingModuleSource) error at the import site, which indicates that the stub file doesn't have a corresponding source file. As long as the import only occurs during typechecking, this can be safely ignored. Autocomplete and typechecking will still work.\n\nNote that since the types don't exist at runtime, they're not compatible with libraries that evaluate annotations at runtime. For example, you can't use them to annotate a field in a Pydantic model.\n\n### Performance\nThe stubs contain a separate overload of `googleapiclient.discovery.build` for each service and version (see `discovery.pyi`). \nThis can lead to slow type inference for this function. Mypy will generally be pretty fast after the first run,\nbut you might experience slow autocomplete in your editor. If you're experiencing this problem you can bypass type inference with explicit annotations, \ne.g. `sheets_service: SheetsResource = build(\"sheets\", \"v4\")` instead of `sheets_service = build(\"sheets\", \"v4\")`.\nNote the caveats to this approach in the previous section.\n\n### Recursive types\nThe stubs previously didn't include recursive type definitions due to a lack of type checker support, but this is now included. Note that if you're using Mypy, v0.990 or higher is required for this to work.\n\n### Stubs for non-API-specific parts\nThere are detailed stubs for the API services, but other parts of the library have only been annotated with [stubgen](https://mypy.readthedocs.io/en/stable/stubgen.html),\nso they're mostly typed as `Any`. I believe these parts are mostly used internally by the library itself,\nso for most users this should be fine. Contributions to improve these stubs are welcome, though.\n",
"bugtrack_url": null,
"license": null,
"summary": "Type stubs for google-api-python-client",
"version": "1.29.0",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "19cc970860afcb563f5c19fffd72f265f5cc7f302bfc61cd838a39749b05d1d1",
"md5": "66b437848d562c1059bd71a7e990f45c",
"sha256": "e874eda842dec69781e4bf4e151b47f6e57cc419ff2c0d1e4719ff8dc3a559fc"
},
"downloads": -1,
"filename": "google_api_python_client_stubs-1.29.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "66b437848d562c1059bd71a7e990f45c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 2907336,
"upload_time": "2025-01-24T20:16:48",
"upload_time_iso_8601": "2025-01-24T20:16:48.186303Z",
"url": "https://files.pythonhosted.org/packages/19/cc/970860afcb563f5c19fffd72f265f5cc7f302bfc61cd838a39749b05d1d1/google_api_python_client_stubs-1.29.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "d89510777e7b965319ad1ac3b8379747040e9002827be18587b313aec0c47fc8",
"md5": "1427f942d25c79d205eee1563a947dc9",
"sha256": "ef88272accb67b92e512e41d04b73651da183c0eabb6028d71b4633e23a9e47e"
},
"downloads": -1,
"filename": "google_api_python_client_stubs-1.29.0.tar.gz",
"has_sig": false,
"md5_digest": "1427f942d25c79d205eee1563a947dc9",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 2089717,
"upload_time": "2025-01-24T20:16:49",
"upload_time_iso_8601": "2025-01-24T20:16:49.995664Z",
"url": "https://files.pythonhosted.org/packages/d8/95/10777e7b965319ad1ac3b8379747040e9002827be18587b313aec0c47fc8/google_api_python_client_stubs-1.29.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-24 20:16:49",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "google-api-python-client-stubs"
}