Skip to content

Commit 6bd9148

Browse files
committed
fix: resolve linting errors and add license header
1 parent 8ad1f91 commit 6bd9148

2 files changed

Lines changed: 32 additions & 10 deletions

File tree

packages/google-auth/google/auth/transport/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,12 @@ def __call__(
121121
# (pylint doesn't play well with abstract docstrings.)
122122
raise NotImplementedError("__call__ must be implemented.")
123123

124-
import sys
124+
125+
import sys # noqa: E402
126+
125127
if sys.version_info < (3, 15):
126128
import importlib
129+
127130
for _lazy_mod in __lazy_modules__:
128131
try:
129132
importlib.import_module(_lazy_mod)
Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# Copyright 2026 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
115
import sys
216
import pytest
317

@@ -8,36 +22,41 @@
822
"google.auth.transport.grpc",
923
]
1024

25+
1126
def clean_sys_modules():
1227
"""Helper to ensure we start with a clean slate for import testing."""
1328
for mod in LAZY_MODULES:
1429
sys.modules.pop(mod, None)
1530

31+
1632
@pytest.mark.skipif(sys.version_info < (3, 15), reason="PEP 810 requires Python 3.15+")
1733
def test_lazy_imports_on_python_315():
1834
clean_sys_modules()
19-
35+
2036
# 1. Import the transport package
21-
import google.auth.transport
22-
37+
import google.auth.transport # noqa: F401
38+
2339
# 2. Assert that none of the lazy modules have been eagerly loaded into sys.modules
2440
for mod in LAZY_MODULES:
2541
assert mod not in sys.modules
26-
42+
2743
# 3. Access an attribute to trigger reification
2844
from google.auth.transport import requests
45+
2946
_ = requests.__name__ # Trigger first-use reification
30-
47+
3148
# 4. Assert that the module has now been reified and loaded
3249
assert "google.auth.transport.requests" in sys.modules
3350

3451

35-
@pytest.mark.skipif(sys.version_info >= (3, 15), reason="Testing fallback behavior on < 3.15")
52+
@pytest.mark.skipif(
53+
sys.version_info >= (3, 15), reason="Testing fallback behavior on < 3.15"
54+
)
3655
def test_fallback_eager_imports_pre_315():
3756
clean_sys_modules()
38-
57+
3958
# On older Python, __lazy_modules__ is safely ignored, meaning they should eager-load
40-
import google.auth.transport
41-
59+
import google.auth.transport # noqa: F401
60+
4261
for mod in LAZY_MODULES:
4362
assert mod in sys.modules

0 commit comments

Comments
 (0)