From 4d7a81bc203792349d55fcf93a59582ee57d59be Mon Sep 17 00:00:00 2001 From: Max Pfeiffer Date: Fri, 5 Apr 2024 11:03:57 +0200 Subject: [PATCH] Switched to Ruff for code formatting Changed pre-commit config. Some files became re-formatted. --- .pre-commit-config.yaml | 10 +++------- core/testcontainers/core/docker_client.py | 1 - modules/influxdb/testcontainers/influxdb.py | 1 + modules/mongodb/testcontainers/mongodb/__init__.py | 2 +- modules/mssql/testcontainers/mssql/__init__.py | 2 +- modules/mysql/testcontainers/mysql/__init__.py | 2 +- modules/mysql/tests/test_mysql.py | 7 ++++--- .../opensearch/testcontainers/opensearch/__init__.py | 2 +- modules/oracle-free/testcontainers/oracle/__init__.py | 2 +- modules/rabbitmq/testcontainers/rabbitmq/__init__.py | 2 +- 10 files changed, 14 insertions(+), 17 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c5b94bdd..5808a000 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,18 +9,14 @@ repos: - id: trailing-whitespace - id: end-of-file-fixer - - repo: https://github.com/psf/black-pre-commit-mirror - rev: '24.2.0' - hooks: - - id: black - args: [ '--config', 'pyproject.toml' ] - - repo: https://github.com/astral-sh/ruff-pre-commit - rev: 'v0.3.0' + rev: 'v0.3.5' hooks: - id: ruff # Explicitly setting config to prevent Ruff from using `pyproject.toml` in sub packages. args: [ '--fix', '--exit-non-zero-on-fix', '--config', 'pyproject.toml' ] + - id: ruff-format + args: [ '--config', 'pyproject.toml' ] # - repo: local # hooks: diff --git a/core/testcontainers/core/docker_client.py b/core/testcontainers/core/docker_client.py index 22a9a4ef..89db0fbf 100644 --- a/core/testcontainers/core/docker_client.py +++ b/core/testcontainers/core/docker_client.py @@ -36,7 +36,6 @@ def _wrapped_container_collection(function: Callable[_P, _T]) -> Callable[_P, _T]: - @ft.wraps(ContainerCollection.run) def wrapper(*args: _P.args, **kwargs: _P.kwargs) -> _T: return function(*args, **kwargs) diff --git a/modules/influxdb/testcontainers/influxdb.py b/modules/influxdb/testcontainers/influxdb.py index 4b9d9b90..d8956e99 100644 --- a/modules/influxdb/testcontainers/influxdb.py +++ b/modules/influxdb/testcontainers/influxdb.py @@ -26,6 +26,7 @@ - because the InfluxDB clients are different for 1.x and 2.x versions, so you won't have to install dependencies that you do not need """ + from typing import Optional from requests import get diff --git a/modules/mongodb/testcontainers/mongodb/__init__.py b/modules/mongodb/testcontainers/mongodb/__init__.py index 32e1f748..4a436b19 100644 --- a/modules/mongodb/testcontainers/mongodb/__init__.py +++ b/modules/mongodb/testcontainers/mongodb/__init__.py @@ -53,7 +53,7 @@ def __init__( username: Optional[str] = None, password: Optional[str] = None, dbname: Optional[str] = None, - **kwargs + **kwargs, ) -> None: raise_for_deprecated_parameter(kwargs, "port_to_expose", "port") super().__init__(image=image, **kwargs) diff --git a/modules/mssql/testcontainers/mssql/__init__.py b/modules/mssql/testcontainers/mssql/__init__.py index 98b66826..3bfe861b 100644 --- a/modules/mssql/testcontainers/mssql/__init__.py +++ b/modules/mssql/testcontainers/mssql/__init__.py @@ -30,7 +30,7 @@ def __init__( port: int = 1433, dbname: str = "tempdb", dialect: str = "mssql+pymssql", - **kwargs + **kwargs, ) -> None: raise_for_deprecated_parameter(kwargs, "user", "username") super().__init__(image, **kwargs) diff --git a/modules/mysql/testcontainers/mysql/__init__.py b/modules/mysql/testcontainers/mysql/__init__.py index 65b317b0..a5b83927 100644 --- a/modules/mysql/testcontainers/mysql/__init__.py +++ b/modules/mysql/testcontainers/mysql/__init__.py @@ -48,7 +48,7 @@ def __init__( password: Optional[str] = None, dbname: Optional[str] = None, port: int = 3306, - **kwargs + **kwargs, ) -> None: raise_for_deprecated_parameter(kwargs, "MYSQL_USER", "username") raise_for_deprecated_parameter(kwargs, "MYSQL_ROOT_PASSWORD", "root_password") diff --git a/modules/mysql/tests/test_mysql.py b/modules/mysql/tests/test_mysql.py index a84df4d1..3506960b 100644 --- a/modules/mysql/tests/test_mysql.py +++ b/modules/mysql/tests/test_mysql.py @@ -40,9 +40,10 @@ def test_docker_run_mariadb(): def test_docker_env_variables(): - with mock.patch.dict("os.environ", MYSQL_USER="demo", MYSQL_DATABASE="custom_db"), MySqlContainer( - "mariadb:10.6.5" - ).with_bind_ports(3306, 32785).maybe_emulate_amd64() as container: + with ( + mock.patch.dict("os.environ", MYSQL_USER="demo", MYSQL_DATABASE="custom_db"), + MySqlContainer("mariadb:10.6.5").with_bind_ports(3306, 32785).maybe_emulate_amd64() as container, + ): url = container.get_connection_url() pattern = r"mysql\+pymysql:\/\/demo:test@[\w,.]+:(3306|32785)\/custom_db" assert re.match(pattern, url) diff --git a/modules/opensearch/testcontainers/opensearch/__init__.py b/modules/opensearch/testcontainers/opensearch/__init__.py index f889c993..06d3a767 100644 --- a/modules/opensearch/testcontainers/opensearch/__init__.py +++ b/modules/opensearch/testcontainers/opensearch/__init__.py @@ -35,7 +35,7 @@ def __init__( image: str = "opensearchproject/opensearch:2.4.0", port: int = 9200, security_enabled: bool = False, - **kwargs + **kwargs, ) -> None: """ Args: diff --git a/modules/oracle-free/testcontainers/oracle/__init__.py b/modules/oracle-free/testcontainers/oracle/__init__.py index 2b903ac5..03f525a7 100644 --- a/modules/oracle-free/testcontainers/oracle/__init__.py +++ b/modules/oracle-free/testcontainers/oracle/__init__.py @@ -36,7 +36,7 @@ def __init__( password: Optional[str] = None, port: int = 1521, dbname: Optional[str] = None, - **kwargs + **kwargs, ) -> None: super().__init__(image=image, **kwargs) diff --git a/modules/rabbitmq/testcontainers/rabbitmq/__init__.py b/modules/rabbitmq/testcontainers/rabbitmq/__init__.py index 0a548602..3e5ad0b3 100644 --- a/modules/rabbitmq/testcontainers/rabbitmq/__init__.py +++ b/modules/rabbitmq/testcontainers/rabbitmq/__init__.py @@ -31,7 +31,7 @@ def __init__( port: Optional[int] = None, username: Optional[str] = None, password: Optional[str] = None, - **kwargs + **kwargs, ) -> None: """Initialize the RabbitMQ test container.