Skip to content

Commit e3fb508

Browse files
committed
Mention the option to quote annotations
1 parent 01e8194 commit e3fb508

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ classes and [TypedDicts](https://docs.python.org/3/library/typing.html#typing.Ty
3434
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.
3535
If you rely solely on type inference, this is not an issue, but as soon as you want to explicitly
3636
annotate a variable, argument or return type in your code with one of these types, you must follow these rules:
37-
1. Put `from __future__ import annotations` at the top of your file. This ensures that annotations are not evaluated at runtime.
38-
This is only supported in 3.7 and up, so for earlier version of Python you need to stick to type inference.
37+
1. Either put `from __future__ import annotations` at the top of your file or surround the annotations with quotes.
38+
This ensures that Python doesn't attempt to evaluate the types at runtime.
39+
Note that the import is only supported in Python 3.7 and above.
3940
2. Only import the types inside an `if typing.TYPE_CHECKING` block. This ensures that the imports are only evaluated during
4041
type checking. Note that any type not available at runtime is located under the `googleapiclient._apis` package.
4142
For example, `SheetsResource` should be imported from `googleapiclient._apis.sheets.v4.resources`.

0 commit comments

Comments
 (0)