Skip to content

Commit 1ff96c7

Browse files
fix lint errors
1 parent 30505c2 commit 1ff96c7

File tree

5 files changed

+10
-9
lines changed

5 files changed

+10
-9
lines changed

google/cloud/alloydb/connector/async_connector.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def __init__(
7575
ip_type: str | IPTypes = IPTypes.PRIVATE,
7676
user_agent: Optional[str] = None,
7777
refresh_strategy: str | RefreshStrategy = RefreshStrategy.BACKGROUND,
78-
static_conn_info: io.TextIOBase = None,
78+
static_conn_info: Optional[io.TextIOBase] = None,
7979
) -> None:
8080
self._cache: dict[str, Union[RefreshAheadCache, LazyRefreshCache]] = {}
8181
# initialize default params
@@ -147,6 +147,7 @@ async def connect(
147147
enable_iam_auth = kwargs.pop("enable_iam_auth", self._enable_iam_auth)
148148

149149
# use existing connection info if possible
150+
cache: Union[RefreshAheadCache, LazyRefreshCache, StaticConnectionInfoCache]
150151
if instance_uri in self._cache:
151152
cache = self._cache[instance_uri]
152153
elif self._static_conn_info:

google/cloud/alloydb/connector/connection_info.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
if TYPE_CHECKING:
2828
import datetime
2929

30-
from cryptography.hazmat.primitives.asymmetric import rsa
30+
from cryptography.hazmat.primitives.asymmetric.types import PrivateKeyTypes
3131

3232
from google.cloud.alloydb.connector.enums import IPTypes
3333

@@ -41,7 +41,7 @@ class ConnectionInfo:
4141

4242
cert_chain: list[str]
4343
ca_cert: str
44-
key: rsa.RSAPrivateKey
44+
key: PrivateKeyTypes
4545
ip_addrs: dict[str, Optional[str]]
4646
expiration: datetime.datetime
4747
context: Optional[ssl.SSLContext] = None

google/cloud/alloydb/connector/connector.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def __init__(
8787
ip_type: str | IPTypes = IPTypes.PRIVATE,
8888
user_agent: Optional[str] = None,
8989
refresh_strategy: str | RefreshStrategy = RefreshStrategy.BACKGROUND,
90-
static_conn_info: io.TextIOBase = None,
90+
static_conn_info: Optional[io.TextIOBase] = None,
9191
) -> None:
9292
# create event loop and start it in background thread
9393
self._loop: asyncio.AbstractEventLoop = asyncio.new_event_loop()
@@ -176,6 +176,7 @@ async def connect_async(self, instance_uri: str, driver: str, **kwargs: Any) ->
176176
)
177177
enable_iam_auth = kwargs.pop("enable_iam_auth", self._enable_iam_auth)
178178
# use existing connection info if possible
179+
cache: Union[RefreshAheadCache, LazyRefreshCache, StaticConnectionInfoCache]
179180
if instance_uri in self._cache:
180181
cache = self._cache[instance_uri]
181182
elif self._static_conn_info:

google/cloud/alloydb/connector/static.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import json
2020

2121
from cryptography.hazmat.primitives import serialization
22-
from cryptography.hazmat.primitives.asymmetric import rsa
2322

2423
from google.cloud.alloydb.connector.connection_info import ConnectionInfo
2524

@@ -70,9 +69,8 @@ def __init__(self, instance_uri: str, static_conn_info: io.TextIOBase) -> None:
7069
}
7170
expiration = datetime.now(timezone.utc) + timedelta(hours=1)
7271
priv_key = static_info["privateKey"]
73-
priv_key_bytes: rsa.RSAPrivateKey = serialization.load_pem_private_key(
74-
priv_key.encode("UTF-8"),
75-
password=None,
72+
priv_key_bytes = serialization.load_pem_private_key(
73+
priv_key.encode("UTF-8"), password=None
7674
)
7775
self._info = ConnectionInfo(
7876
cert_chain, ca_cert, priv_key_bytes, ip_addrs, expiration

google/cloud/alloydb/connector/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@
1717
import aiofiles
1818
from cryptography.hazmat.primitives import serialization
1919
from cryptography.hazmat.primitives.asymmetric import rsa
20+
from cryptography.hazmat.primitives.asymmetric.types import PrivateKeyTypes
2021

2122

2223
async def _write_to_file(
23-
dir_path: str, ca_cert: str, cert_chain: list[str], key: rsa.RSAPrivateKey
24+
dir_path: str, ca_cert: str, cert_chain: list[str], key: PrivateKeyTypes
2425
) -> tuple[str, str, str]:
2526
"""
2627
Helper function to write the server_ca, client certificate and

0 commit comments

Comments
 (0)