Skip to content

Commit

Permalink
fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
rhatgadkar-goog committed Jan 31, 2025
1 parent 30505c2 commit 1ff96c7
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
3 changes: 2 additions & 1 deletion google/cloud/alloydb/connector/async_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def __init__(
ip_type: str | IPTypes = IPTypes.PRIVATE,
user_agent: Optional[str] = None,
refresh_strategy: str | RefreshStrategy = RefreshStrategy.BACKGROUND,
static_conn_info: io.TextIOBase = None,
static_conn_info: Optional[io.TextIOBase] = None,
) -> None:
self._cache: dict[str, Union[RefreshAheadCache, LazyRefreshCache]] = {}
# initialize default params
Expand Down Expand Up @@ -147,6 +147,7 @@ async def connect(
enable_iam_auth = kwargs.pop("enable_iam_auth", self._enable_iam_auth)

# use existing connection info if possible
cache: Union[RefreshAheadCache, LazyRefreshCache, StaticConnectionInfoCache]
if instance_uri in self._cache:
cache = self._cache[instance_uri]
elif self._static_conn_info:
Expand Down
4 changes: 2 additions & 2 deletions google/cloud/alloydb/connector/connection_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
if TYPE_CHECKING:
import datetime

from cryptography.hazmat.primitives.asymmetric import rsa
from cryptography.hazmat.primitives.asymmetric.types import PrivateKeyTypes

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

Expand All @@ -41,7 +41,7 @@ class ConnectionInfo:

cert_chain: list[str]
ca_cert: str
key: rsa.RSAPrivateKey
key: PrivateKeyTypes
ip_addrs: dict[str, Optional[str]]
expiration: datetime.datetime
context: Optional[ssl.SSLContext] = None
Expand Down
3 changes: 2 additions & 1 deletion google/cloud/alloydb/connector/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def __init__(
ip_type: str | IPTypes = IPTypes.PRIVATE,
user_agent: Optional[str] = None,
refresh_strategy: str | RefreshStrategy = RefreshStrategy.BACKGROUND,
static_conn_info: io.TextIOBase = None,
static_conn_info: Optional[io.TextIOBase] = None,
) -> None:
# create event loop and start it in background thread
self._loop: asyncio.AbstractEventLoop = asyncio.new_event_loop()
Expand Down Expand Up @@ -176,6 +176,7 @@ async def connect_async(self, instance_uri: str, driver: str, **kwargs: Any) ->
)
enable_iam_auth = kwargs.pop("enable_iam_auth", self._enable_iam_auth)
# use existing connection info if possible
cache: Union[RefreshAheadCache, LazyRefreshCache, StaticConnectionInfoCache]
if instance_uri in self._cache:
cache = self._cache[instance_uri]
elif self._static_conn_info:
Expand Down
6 changes: 2 additions & 4 deletions google/cloud/alloydb/connector/static.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import json

from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric import rsa

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

Expand Down Expand Up @@ -70,9 +69,8 @@ def __init__(self, instance_uri: str, static_conn_info: io.TextIOBase) -> None:
}
expiration = datetime.now(timezone.utc) + timedelta(hours=1)
priv_key = static_info["privateKey"]
priv_key_bytes: rsa.RSAPrivateKey = serialization.load_pem_private_key(
priv_key.encode("UTF-8"),
password=None,
priv_key_bytes = serialization.load_pem_private_key(
priv_key.encode("UTF-8"), password=None
)
self._info = ConnectionInfo(
cert_chain, ca_cert, priv_key_bytes, ip_addrs, expiration
Expand Down
3 changes: 2 additions & 1 deletion google/cloud/alloydb/connector/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
import aiofiles
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric import rsa
from cryptography.hazmat.primitives.asymmetric.types import PrivateKeyTypes


async def _write_to_file(
dir_path: str, ca_cert: str, cert_chain: list[str], key: rsa.RSAPrivateKey
dir_path: str, ca_cert: str, cert_chain: list[str], key: PrivateKeyTypes
) -> tuple[str, str, str]:
"""
Helper function to write the server_ca, client certificate and
Expand Down

0 comments on commit 1ff96c7

Please sign in to comment.