You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,8 +34,9 @@ classes and [TypedDicts](https://docs.python.org/3/library/typing.html#typing.Ty
34
34
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.
35
35
If you rely solely on type inference, this is not an issue, but as soon as you want to explicitly
36
36
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.
39
40
2. Only import the types inside an `if typing.TYPE_CHECKING` block. This ensures that the imports are only evaluated during
40
41
type checking. Note that any type not available at runtime is located under the `googleapiclient._apis` package.
41
42
For example, `SheetsResource` should be imported from `googleapiclient._apis.sheets.v4.resources`.
0 commit comments