| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c341469 commit 5a7ed02
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,3 +9,11 @@ exclude = | |||
| 9 | 9 | .git, | |
| 10 | 10 | *.pyc, | |
| 11 | 11 | conf.py | |
| 12 | + # PEP 0810 lazy imports require __lazy_modules__ to precede import statements, | ||
| 13 | + # which causes flake8 to flag module-level imports as E402. | ||
| 14 | + per-file-ignores = | ||
| 15 | + google/cloud/_helpers/__init__.py: E402 | ||
| 16 | + google/cloud/_http/__init__.py: E402 | ||
| 17 | + google/cloud/client/__init__.py: E402 | ||
| 18 | + google/cloud/exceptions/__init__.py: E402 | ||
| 19 | + google/cloud/operation/__init__.py: E402 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,7 +25,25 @@ | |||
| 25 | 25 | import os | |
| 26 | 26 | import re | |
| 27 | 27 | from threading import local as Local | |
| 28 | - from typing import Union | ||
| 28 | + from typing import Set, Union | ||
| 29 | + | ||
| 30 | + # PEP 0810: Explicit Lazy Imports | ||
| 31 | + # Python 3.15+ natively intercepts and defers these imports. | ||
| 32 | + # Developers can disable this behavior and force eager imports. | ||
| 33 | + # For more information, see: | ||
| 34 | + # https://docs.python.org/3.15/library/sys.html#sys.set_lazy_imports_filter | ||
| 35 | + # Older Python versions safely ignore this variable. | ||
| 36 | + # NOTE: We statically define all modules here to ensure static analysis tools | ||
| 37 | + # (mypy, pyright, Ruff) can easily parse them. If support is not present, the | ||
| 38 | + # imports are ignored, making their presence safe. | ||
| 39 | + __lazy_modules__: Set[str] = { | ||
| 40 | + "google.auth", | ||
| 41 | + "google.auth.transport.grpc", | ||
| 42 | + "google.auth.transport.requests", | ||
| 43 | + "google.protobuf.duration_pb2", | ||
| 44 | + "google.protobuf.timestamp_pb2", | ||
| 45 | + "grpc", | ||
| 46 | + } | ||
| 29 | 47 | ||
| 30 | 48 | import google.auth | |
| 31 | 49 | import google.auth.transport.requests | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,10 +19,25 @@ | |||
| 19 | 19 | import json | |
| 20 | 20 | import os | |
| 21 | 21 | import platform | |
| 22 | - from typing import Optional | ||
| 22 | + from typing import Optional, Set | ||
| 23 | 23 | from urllib.parse import urlencode | |
| 24 | 24 | import warnings | |
| 25 | 25 | ||
| 26 | + # PEP 0810: Explicit Lazy Imports | ||
| 27 | + # Python 3.15+ natively intercepts and defers these imports. | ||
| 28 | + # Developers can disable this behavior and force eager imports. | ||
| 29 | + # For more information, see: | ||
| 30 | + # https://docs.python.org/3.15/library/sys.html#sys.set_lazy_imports_filter | ||
| 31 | + # Older Python versions safely ignore this variable. | ||
| 32 | + # NOTE: We statically define all modules here to ensure static analysis tools | ||
| 33 | + # (mypy, pyright, Ruff) can easily parse them. If support is not present, the | ||
| 34 | + # imports are ignored, making their presence safe. | ||
| 35 | + __lazy_modules__: Set[str] = { | ||
| 36 | + "google.api_core.client_info", | ||
| 37 | + "google.cloud.exceptions", | ||
| 38 | + "google.cloud.version", | ||
| 39 | + } | ||
| 40 | + | ||
| 26 | 41 | from google.api_core.client_info import ClientInfo | |
| 27 | 42 | from google.cloud import exceptions | |
| 28 | 43 | from google.cloud import version | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,8 +18,29 @@ | |||
| 18 | 18 | import json | |
| 19 | 19 | import os | |
| 20 | 20 | from pickle import PicklingError | |
| 21 | - from typing import Tuple | ||
| 22 | - from typing import Union | ||
| 21 | + from typing import Set, Tuple, Union | ||
| 22 | + | ||
| 23 | + # PEP 0810: Explicit Lazy Imports | ||
| 24 | + # Python 3.15+ natively intercepts and defers these imports. | ||
| 25 | + # Developers can disable this behavior and force eager imports. | ||
| 26 | + # For more information, see: | ||
| 27 | + # https://docs.python.org/3.15/library/sys.html#sys.set_lazy_imports_filter | ||
| 28 | + # Older Python versions safely ignore this variable. | ||
| 29 | + # NOTE: We statically define all modules here to ensure static analysis tools | ||
| 30 | + # (mypy, pyright, Ruff) can easily parse them. If support is not present, the | ||
| 31 | + # imports are ignored, making their presence safe. | ||
| 32 | + __lazy_modules__: Set[str] = { | ||
| 33 | + "google.api_core.client_options", | ||
| 34 | + "google.api_core.exceptions", | ||
| 35 | + "google.auth", | ||
| 36 | + "google.auth.api_key", | ||
| 37 | + "google.auth.environment_vars", | ||
| 38 | + "google.auth.credentials", | ||
| 39 | + "google.auth.transport.requests", | ||
| 40 | + "google.cloud._helpers", | ||
| 41 | + "google.oauth2", | ||
| 42 | + "google.oauth2.service_account", | ||
| 43 | + } | ||
| 23 | 44 | ||
| 24 | 45 | import google.api_core.client_options | |
| 25 | 46 | import google.api_core.exceptions | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,6 +21,23 @@ | |||
| 21 | 21 | # Avoid the grpc and google.cloud.grpc collision. | |
| 22 | 22 | from __future__ import absolute_import | |
| 23 | 23 | ||
| 24 | + from typing import Set | ||
| 25 | + | ||
| 26 | + # PEP 0810: Explicit Lazy Imports | ||
| 27 | + # Python 3.15+ natively intercepts and defers these imports. | ||
| 28 | + # Developers can disable this behavior and force eager imports. | ||
| 29 | + # For more information, see: | ||
| 30 | + # https://docs.python.org/3.15/library/sys.html#sys.set_lazy_imports_filter | ||
| 31 | + # Older Python versions safely ignore this variable. | ||
| 32 | + # NOTE: We statically define all modules here to ensure static analysis tools | ||
| 33 | + # (mypy, pyright, Ruff) can easily parse them. If support is not present, the | ||
| 34 | + # imports are ignored, making their presence safe. | ||
| 35 | + __lazy_modules__: Set[str] = { | ||
| 36 | + "google.api_core.exceptions", | ||
| 37 | + "grpc", | ||
| 38 | + "grpc._channel", | ||
| 39 | + } | ||
| 40 | + | ||
| 24 | 41 | from google.api_core import exceptions | |
| 25 | 42 | ||
| 26 | 43 | try: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,7 +14,23 @@ | |||
| 14 | 14 | ||
| 15 | 15 | """Wrap long-running operations returned from Google Cloud APIs.""" | |
| 16 | 16 | ||
| 17 | - from typing import Dict | ||
| 17 | + from typing import Dict, Set | ||
| 18 | + | ||
| 19 | + # PEP 0810: Explicit Lazy Imports | ||
| 20 | + # Python 3.15+ natively intercepts and defers these imports. | ||
| 21 | + # Developers can disable this behavior and force eager imports. | ||
| 22 | + # For more information, see: | ||
| 23 | + # https://docs.python.org/3.15/library/sys.html#sys.set_lazy_imports_filter | ||
| 24 | + # Older Python versions safely ignore this variable. | ||
| 25 | + # NOTE: We statically define all modules here to ensure static analysis tools | ||
| 26 | + # (mypy, pyright, Ruff) can easily parse them. If support is not present, the | ||
| 27 | + # imports are ignored, making their presence safe. | ||
| 28 | + __lazy_modules__: Set[str] = { | ||
| 29 | + "google.longrunning", | ||
| 30 | + "google.longrunning.operations_pb2", | ||
| 31 | + "google.protobuf", | ||
| 32 | + "google.protobuf.json_format", | ||
| 33 | + } | ||
| 18 | 34 | ||
| 19 | 35 | from google.longrunning import operations_pb2 | |
| 20 | 36 | from google.protobuf import json_format | |
| Back | FazBrowse Home | New Git URL |
0 commit comments