From 7a6e578acfefcedb02d35bcab8f4dc869ca188f6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 20 Aug 2024 10:33:23 +0200 Subject: [PATCH] [pre-commit.ci] pre-commit autoupdate (#178) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [pre-commit.ci] pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.5.7 → v0.6.1](https://github.com/astral-sh/ruff-pre-commit/compare/v0.5.7...v0.6.1) * [pre-commit.ci] auto fixes from pre-commit hooks For more information, see https://pre-commit.ci * Update ruff config Include docs/example/** in the per-file-ignore section, adding blind excepts, print-statements, and ignore required imports (i.e., don't force include the `from __future__ import annotations`. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Casper Welzel Andersen --- .pre-commit-config.yaml | 2 +- pyproject.toml | 9 +++++++-- tests/cli/commands/conftest.py | 10 +++++----- tests/cli/commands/test_config.py | 2 +- tests/cli/conftest.py | 6 +++--- tests/conftest.py | 16 ++++++++-------- tests/service/backend/test_mongodb.py | 2 +- tests/service/test_security.py | 4 ++-- 8 files changed, 28 insertions(+), 23 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a3ffc41..85d9231 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -41,7 +41,7 @@ repos: # Ruff is a code style and formatter # It works on files in-place - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.5.7 + rev: v0.6.1 hooks: - id: ruff args: diff --git a/pyproject.toml b/pyproject.toml index a7ea3df..6dd9524 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -126,11 +126,16 @@ ignore = [ isort.required-imports = ["from __future__ import annotations"] [tool.ruff.lint.per-file-ignores] -"tests/**" = [ +".github/**" = [ "BLE", # flake8-blind-except "T20", # flake8-print ] -".github/**" = [ +"docs/example/**" = [ + "BLE", # flake8-blind-except + "I002", # missing-required-import + "T20", # flake8-print +] +"tests/**" = [ "BLE", # flake8-blind-except "T20", # flake8-print ] diff --git a/tests/cli/commands/conftest.py b/tests/cli/commands/conftest.py index 381848e..06595a9 100644 --- a/tests/cli/commands/conftest.py +++ b/tests/cli/commands/conftest.py @@ -41,7 +41,7 @@ def list_app() -> Typer: return APP -@pytest.fixture() +@pytest.fixture def dotenv_file(tmp_path: Path) -> Path: """Create a path to a dotenv file in a temporary test folder.""" from entities_service.service.config import CONFIG @@ -53,7 +53,7 @@ def dotenv_file(tmp_path: Path) -> Path: return tmp_path / env_file -@pytest.fixture() +@pytest.fixture def _mock_config_base_url(monkeypatch: pytest.MonkeyPatch, live_backend: bool) -> None: """Mock the base url if using a live backend.""" if not live_backend: @@ -77,7 +77,7 @@ def _mock_config_base_url(monkeypatch: pytest.MonkeyPatch, live_backend: bool) - ) -@pytest.fixture() +@pytest.fixture def non_mocked_hosts(live_backend: bool) -> list[str]: """Return a list of hosts that are not mocked by 'pytest-httpx.""" if not live_backend: @@ -104,7 +104,7 @@ def non_mocked_hosts(live_backend: bool) -> list[str]: return hosts -@pytest.fixture() +@pytest.fixture def _mock_successful_oauth_response( monkeypatch: pytest.MonkeyPatch, token_mock: str, httpx_mock: HTTPXMock ) -> None: @@ -124,7 +124,7 @@ def _mock_successful_oauth_response( ) -@pytest.fixture() +@pytest.fixture def _mock_failed_oauth_response( monkeypatch: pytest.MonkeyPatch, httpx_mock: HTTPXMock ) -> None: diff --git a/tests/cli/commands/test_config.py b/tests/cli/commands/test_config.py index e6bd9bd..c8ccdb2 100644 --- a/tests/cli/commands/test_config.py +++ b/tests/cli/commands/test_config.py @@ -15,7 +15,7 @@ pytestmark = pytest.mark.usefixtures("_mock_config_base_url") -@pytest.fixture() +@pytest.fixture def _prefill_dotenv_config(dotenv_file: Path) -> None: """'Pre'-fill the monkeypatched dotenv config paths.""" from dotenv import set_key diff --git a/tests/cli/conftest.py b/tests/cli/conftest.py index dc09ebf..f19aedc 100644 --- a/tests/cli/conftest.py +++ b/tests/cli/conftest.py @@ -12,7 +12,7 @@ from typer.testing import CliRunner -@pytest.fixture() +@pytest.fixture def cli() -> CliRunner: """Fixture for CLI runner.""" import os @@ -22,7 +22,7 @@ def cli() -> CliRunner: return CliRunner(mix_stderr=False, env=os.environ.copy()) -@pytest.fixture() +@pytest.fixture def tmp_cache_dir(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path: """Create a temporary cache directory.""" cache_dir = tmp_path / ".cache" / "entities-service" @@ -37,7 +37,7 @@ def tmp_cache_dir(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path: return cache_dir -@pytest.fixture() +@pytest.fixture def tmp_cache_file(tmp_cache_dir: Path) -> Path: """Create a temporary cache file.""" return tmp_cache_dir / "oauth2_token_cache.json" diff --git a/tests/conftest.py b/tests/conftest.py index 0f0663b..59fc5b9 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -539,7 +539,7 @@ def _setup_real_mongo_users( ) -@pytest.fixture() +@pytest.fixture def existing_specific_namespace() -> str: """Return the specific namespace to test.""" return "test" @@ -632,7 +632,7 @@ def _reset_mongo_test_collections( ) -@pytest.fixture() +@pytest.fixture def _empty_backend_collection( get_backend_user: GetBackendUserFixture, existing_specific_namespace: str, @@ -656,7 +656,7 @@ def _empty_backend_collection( assert backend._collection.count_documents({}) == 0 -@pytest.fixture() +@pytest.fixture def token_mock() -> str: """Return a mock token. @@ -670,7 +670,7 @@ def token_mock() -> str: ) -@pytest.fixture() +@pytest.fixture def auth_header(token_mock: str) -> dict[Literal["Authorization"], str]: """Return the authentication header.""" from fastapi.security import HTTPAuthorizationCredentials @@ -684,7 +684,7 @@ def auth_header(token_mock: str) -> dict[Literal["Authorization"], str]: } -@pytest.fixture() +@pytest.fixture def openid_config_mock() -> OpenIDConfigMock: """Return a mock OpenID configuration.""" @@ -705,7 +705,7 @@ def _openid_config_mock(base_url: str) -> dict[str, Any]: return _openid_config_mock -@pytest.fixture() +@pytest.fixture def mock_openid_config_call( httpx_mock: HTTPXMock, openid_config_mock: OpenIDConfigMock ) -> MockOpenIDConfigCall: @@ -721,7 +721,7 @@ def _mock_openid_config_call(base_url: str) -> None: return _mock_openid_config_call -@pytest.fixture() +@pytest.fixture def mock_auth_verification( httpx_mock: HTTPXMock, get_backend_user: GetBackendUserFixture, @@ -784,7 +784,7 @@ def _mock_auth_verification( return _mock_auth_verification -@pytest.fixture() +@pytest.fixture def client( live_backend: bool, auth_header: dict[Literal["Authorization"], str] ) -> ClientFixture: diff --git a/tests/service/backend/test_mongodb.py b/tests/service/backend/test_mongodb.py index 072975b..6756c2f 100644 --- a/tests/service/backend/test_mongodb.py +++ b/tests/service/backend/test_mongodb.py @@ -21,7 +21,7 @@ def __call__( ) -> MongoDBBackend: ... -@pytest.fixture() +@pytest.fixture def mongo_backend(get_backend_user: GetBackendUserFixture) -> GetMongoBackend: """Get a MongoDB backend.""" diff --git a/tests/service/test_security.py b/tests/service/test_security.py index fd4133c..1a77535 100644 --- a/tests/service/test_security.py +++ b/tests/service/test_security.py @@ -14,7 +14,7 @@ from ..conftest import MockOpenIDConfigCall, OpenIDConfigMock -@pytest.fixture() +@pytest.fixture def user_info() -> dict[str, Any]: """Test data for verify_user_access_token() function.""" return { @@ -46,7 +46,7 @@ def user_info() -> dict[str, Any]: } -@pytest.fixture() +@pytest.fixture def group_member_info() -> dict[str, Any]: """Test data for verify_user_access_token() function.""" return {