Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion google/cloud/sql/connector/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
import aiohttp
from cryptography.hazmat.backends import default_backend
from cryptography.x509 import load_pem_x509_certificate

from google.auth.credentials import TokenState
from google.auth.transport import requests

from google.cloud.sql.connector.connection_info import ConnectionInfo
from google.cloud.sql.connector.connection_name import ConnectionName
from google.cloud.sql.connector.exceptions import AutoIAMAuthNotSupported
Expand Down
1 change: 0 additions & 1 deletion google/cloud/sql/connector/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import google.auth
from google.auth.credentials import Credentials
from google.auth.credentials import with_scopes_if_required

import google.cloud.sql.connector.asyncpg as asyncpg
from google.cloud.sql.connector.client import CloudSQLClient
from google.cloud.sql.connector.enums import DriverMapping
Expand Down
1 change: 1 addition & 0 deletions google/cloud/sql/connector/refresh_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from typing import Any, Callable

import aiohttp

from google.auth.credentials import Credentials
from google.auth.credentials import Scoped
import google.auth.transport.requests
Expand Down
4 changes: 2 additions & 2 deletions google/cloud/sql/connector/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@

import dns.asyncresolver

from google.cloud.sql.connector.connection_name import _is_valid_domain
from google.cloud.sql.connector.connection_name import _parse_connection_name
from google.cloud.sql.connector.connection_name import (
_parse_connection_name_with_domain_name,
)
from google.cloud.sql.connector.connection_name import _is_valid_domain
from google.cloud.sql.connector.connection_name import _parse_connection_name
from google.cloud.sql.connector.connection_name import ConnectionName
from google.cloud.sql.connector.exceptions import DnsResolutionError

Expand Down
49 changes: 9 additions & 40 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@

import nox

BLACK_VERSION = "black==24.10.0"
ISORT_VERSION = "isort==5.13.2"

LINT_PATHS = ["google", "tests", "noxfile.py"]

TEST_PYTHON_VERSIONS = ["3.9", "3.10", "3.11", "3.12", "3.13"]
Expand All @@ -36,32 +33,16 @@ def lint(session):
"""
session.install("-r", "requirements.txt")
session.install(
"flake8",
"flake8-annotations",
"ruff",
"mypy",
BLACK_VERSION,
ISORT_VERSION,
"twine",
"build",
"importlib_metadata==7.2.1",
)
session.run(
"isort",
"--fss",
"--check-only",
"--diff",
"--profile=black",
"--force-single-line-imports",
"--dont-order-by-type",
"--single-line-exclusions=typing",
"-w=88",
*LINT_PATHS,
)
session.run("black", "--check", "--diff", *LINT_PATHS)
session.run(
"flake8",
"google",
"tests",
"ruff",
"check",
*LINT_PATHS,
)
session.run(
"mypy",
Expand All @@ -75,28 +56,16 @@ def lint(session):
session.run("python", "-m", "build", "--sdist")
session.run("twine", "check", "--strict", "dist/*")


@nox.session()
def format(session):
"""
Run isort to sort imports. Then run black
to format code to uniform standard.
Run Ruff to automatically format code.
"""
session.install(BLACK_VERSION, ISORT_VERSION)
# Use the --fss option to sort imports using strict alphabetical order.
# See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sectionss
session.run(
"isort",
"--fss",
"--profile=black",
"--force-single-line-imports",
"--dont-order-by-type",
"--single-line-exclusions=typing",
"-w=88",
*LINT_PATHS,
)
session.install("ruff")
session.run(
"black",
"ruff",
"check",
"--fix",
*LINT_PATHS,
)

Expand Down
12 changes: 12 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,15 @@ exclude = ['docs/*', 'samples/*']

[tool.pytest.ini_options]
asyncio_mode = "auto"

[tool.ruff.lint]
extend-select = ["I"]

[tool.ruff.lint.isort]
force-single-line = true
force-sort-within-sections = true
order-by-type = false
single-line-exclusions = ["typing"]

[tool.ruff.format]
quote-style = "double"
2 changes: 1 addition & 1 deletion tests/unit/mocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric import rsa
from cryptography.x509.oid import NameOID

from google.auth import _helpers
from google.auth.credentials import Credentials
from google.auth.credentials import TokenState

from google.cloud.sql.connector.connector import _DEFAULT_UNIVERSE_DOMAIN
from google.cloud.sql.connector.utils import generate_keys
from google.cloud.sql.connector.utils import write_to_file
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

from aiohttp import ClientResponseError
from aioresponses import aioresponses
from google.auth.credentials import Credentials
from mocks import FakeCredentials
import pytest

from google.auth.credentials import Credentials
from google.cloud.sql.connector.client import CloudSQLClient
from google.cloud.sql.connector.utils import generate_keys
from google.cloud.sql.connector.version import __version__ as version
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
from typing import Union

from aiohttp import ClientResponseError
from google.auth.credentials import Credentials
from mock import patch
import pytest # noqa F401 Needed to run the tests

from google.auth.credentials import Credentials
from google.cloud.sql.connector import Connector
from google.cloud.sql.connector import create_async_connector
from google.cloud.sql.connector import IPTypes
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/test_refresh_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@
import datetime

from conftest import SCOPES # type: ignore
import google.auth
from google.auth.credentials import Credentials
from google.auth.credentials import TokenState
import google.oauth2.credentials
from mock import Mock
from mock import patch
import pytest # noqa F401 Needed to run the tests

import google.auth
from google.auth.credentials import Credentials
from google.auth.credentials import TokenState
from google.cloud.sql.connector.refresh_utils import _downscope_credentials
from google.cloud.sql.connector.refresh_utils import _exponential_backoff
from google.cloud.sql.connector.refresh_utils import _is_valid
from google.cloud.sql.connector.refresh_utils import _seconds_until_refresh
from google.cloud.sql.connector.refresh_utils import retry_50x
import google.oauth2.credentials


@pytest.fixture
Expand Down
Loading