Skip to content

Commit 48f4e26

Browse files
committed
fix: resolve mypy and lint issues
1 parent 19f9699 commit 48f4e26

5 files changed

Lines changed: 14 additions & 14 deletions

File tree

packages/google-auth/google/auth/aio/transport/mtls.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,13 @@
1717
"""
1818

1919
import asyncio
20-
import contextlib
2120
import logging
22-
import os
2321
import ssl
24-
import tempfile
2522
from typing import Optional
2623

2724
from google.auth import exceptions
28-
import google.auth.transport.mtls
2925
from google.auth.transport._mtls_helper import secure_cert_key_paths
26+
import google.auth.transport.mtls
3027

3128
_LOGGER = logging.getLogger(__name__)
3229

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from os import environ, getenv, path
2121
import re
2222
import subprocess
23-
from typing import Generator, Optional, Tuple, Union
23+
from typing import cast, Generator, Optional, Tuple, Union
2424

2525
from google.auth import _agent_identity_utils
2626
from google.auth import environment_vars
@@ -118,7 +118,9 @@ def secure_cert_key_paths(
118118
if (cert_path is None or os.path.exists(cert_path)) and (
119119
key_path is None or os.path.exists(key_path)
120120
):
121-
yield cert_path or cert, key_path or key, passphrase
121+
yield cast(str, cert_path or cert), cast(
122+
str, key_path or key
123+
), passphrase
122124
return
123125
finally:
124126
import sys
@@ -137,7 +139,7 @@ def secure_cert_key_paths(
137139
key_path,
138140
new_passphrase,
139141
):
140-
yield cert_path or cert, key_path or key, new_passphrase
142+
yield cast(str, cert_path or cert), cast(str, key_path or key), new_passphrase
141143

142144

143145
def _encrypt_key_if_plaintext(
@@ -199,7 +201,9 @@ def _secure_wipe_and_remove(file_path: str):
199201

200202

201203
@contextlib.contextmanager
202-
def _memfd_cert_key_paths(cert_bytes: Optional[bytes], key_bytes: Optional[bytes]):
204+
def _memfd_cert_key_paths(
205+
cert_bytes: Optional[bytes], key_bytes: Optional[bytes]
206+
) -> Generator[Tuple[Optional[str], Optional[str]], None, None]:
203207
"""Creates secure, in-memory virtual files on Linux using memfd_create.
204208
205209
Yields:
@@ -237,8 +241,10 @@ def _memfd_cert_key_paths(cert_bytes: Optional[bytes], key_bytes: Optional[bytes
237241

238242
@contextlib.contextmanager
239243
def _tempfile_cert_key_paths(
240-
cert_bytes: Optional[bytes], key_bytes: Optional[bytes], passphrase: Optional[bytes]
241-
):
244+
cert_bytes: Optional[bytes],
245+
key_bytes: Optional[bytes],
246+
passphrase: Optional[bytes],
247+
) -> Generator[Tuple[Optional[str], Optional[str], Optional[bytes]], None, None]:
242248
"""Creates secure temporary file paths on disk, encrypting private keys.
243249
244250
Yields:

packages/google-auth/tests/transport/test__mtls_helper.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@
1616
import re
1717
from unittest import mock
1818

19-
from cryptography.hazmat.primitives import serialization
19+
from cryptography.hazmat.primitives import hashes, serialization
2020
from cryptography.hazmat.primitives.asymmetric import ec
21-
from cryptography.hazmat.primitives import hashes
2221
import pytest # type: ignore
2322

2423
from google.auth import environment_vars, exceptions

packages/google-auth/tests/transport/test_requests.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import functools
1717
import http.client as http_client
1818
import os
19-
import sys
2019
from unittest import mock
2120

2221
import freezegun

packages/google-auth/tests/transport/test_urllib3.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
import http.client as http_client
1616
import os
17-
import sys
1817
from unittest import mock
1918

2019
import pytest # type: ignore

0 commit comments

Comments
 (0)