diff --git a/.github/workflows/cd_release.yml b/.github/workflows/cd_release.yml index 967f139a..34be237a 100644 --- a/.github/workflows/cd_release.yml +++ b/.github/workflows/cd_release.yml @@ -8,7 +8,7 @@ on: jobs: release: name: External - uses: SINTEF/ci-cd/.github/workflows/cd_release.yml@v2.8.3 + uses: SINTEF/ci-cd/.github/workflows/cd_release.yml@v2.9.0 if: github.repository == 'SINTEF/entities-service' && startsWith(github.ref, 'refs/tags/v') with: # General diff --git a/.github/workflows/ci_automerge_dependencies.yml b/.github/workflows/ci_automerge_dependencies.yml index d9d1a4ed..5e660b12 100644 --- a/.github/workflows/ci_automerge_dependencies.yml +++ b/.github/workflows/ci_automerge_dependencies.yml @@ -7,7 +7,7 @@ on: jobs: update-dependencies-branch: name: External - uses: SINTEF/ci-cd/.github/workflows/ci_automerge_prs.yml@v2.8.3 + uses: SINTEF/ci-cd/.github/workflows/ci_automerge_prs.yml@v2.9.0 if: github.repository_owner == 'SINTEF' && ( ( startsWith(github.event.pull_request.head.ref, 'dependabot/') && github.actor == 'dependabot[bot]' ) || ( github.event.pull_request.head.ref == 'ci/update-pyproject' && github.actor == 'TEAM4-0' ) || ( github.event.pull_request.head.ref == 'pre-commit-ci-update-config' && github.actor == 'pre-commit-ci[bot]' ) ) secrets: PAT: ${{ secrets.TEAM40_PAT }} diff --git a/.github/workflows/ci_cd_updated_main.yml b/.github/workflows/ci_cd_updated_main.yml index f3865ac1..d69d42d5 100644 --- a/.github/workflows/ci_cd_updated_main.yml +++ b/.github/workflows/ci_cd_updated_main.yml @@ -7,7 +7,7 @@ on: jobs: update-deps-branch-and-docs: name: External - uses: SINTEF/ci-cd/.github/workflows/ci_cd_updated_default_branch.yml@v2.8.3 + uses: SINTEF/ci-cd/.github/workflows/ci_cd_updated_default_branch.yml@v2.9.0 if: github.repository_owner == 'SINTEF' with: # General diff --git a/.github/workflows/ci_check_dependencies.yml b/.github/workflows/ci_check_dependencies.yml index 2c58627b..1e7fd960 100644 --- a/.github/workflows/ci_check_dependencies.yml +++ b/.github/workflows/ci_check_dependencies.yml @@ -9,7 +9,7 @@ on: jobs: check-dependencies: name: External - uses: SINTEF/ci-cd/.github/workflows/ci_check_pyproject_dependencies.yml@v2.8.3 + uses: SINTEF/ci-cd/.github/workflows/ci_check_pyproject_dependencies.yml@v2.9.0 if: github.repository_owner == 'SINTEF' with: git_username: "TEAM 4.0[bot]" diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index 7c8b5ea2..b99bc991 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -10,7 +10,7 @@ on: jobs: basic-tests: name: External - uses: SINTEF/ci-cd/.github/workflows/ci_tests.yml@v2.8.3 + uses: SINTEF/ci-cd/.github/workflows/ci_tests.yml@v2.9.0 with: # General setup install_extras: "[dev]" diff --git a/.github/workflows/ci_update_dependencies.yml b/.github/workflows/ci_update_dependencies.yml index a28969a7..dc980566 100644 --- a/.github/workflows/ci_update_dependencies.yml +++ b/.github/workflows/ci_update_dependencies.yml @@ -9,7 +9,7 @@ on: jobs: create-collected-pr: name: External - uses: SINTEF/ci-cd/.github/workflows/ci_update_dependencies.yml@v2.8.3 + uses: SINTEF/ci-cd/.github/workflows/ci_update_dependencies.yml@v2.9.0 if: github.repository_owner == 'SINTEF' with: # General diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 32892244..17ef35a2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -34,14 +34,14 @@ repos: # Black is a code style and formatter # It works on files in-place - repo: https://github.com/psf/black - rev: 24.10.0 + rev: 25.1.0 hooks: - id: black # Ruff is a code style and formatter # It works on files in-place - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.9.3 + rev: v0.9.4 hooks: - id: ruff args: diff --git a/entities_service/cli/commands/login.py b/entities_service/cli/commands/login.py index 06f4dfd6..0e2d9250 100644 --- a/entities_service/cli/commands/login.py +++ b/entities_service/cli/commands/login.py @@ -40,17 +40,17 @@ def login( with httpx.Client(base_url=str(CONFIG.base_url), timeout=10) as client: try: response = client.post("/_admin/create", json=[], auth=oauth) - except httpx.HTTPError as exc: - ERROR_CONSOLE.print( - f"[bold red]Error[/bold red]: Could not login. HTTP exception: {exc}" - ) - raise typer.Exit(1) from exc except AuthenticationError as exc: ERROR_CONSOLE.print( f"[bold red]Error[/bold red]: Could not login. Authentication failed " f"({exc.__class__.__name__}): {exc}" ) raise typer.Exit(1) from exc + except httpx.HTTPError as exc: + ERROR_CONSOLE.print( + f"[bold red]Error[/bold red]: Could not login. HTTP exception: {exc}" + ) + raise typer.Exit(1) from exc except json.JSONDecodeError as exc: ERROR_CONSOLE.print( f"[bold red]Error[/bold red]: Could not login. JSON decode error: {exc}" diff --git a/entities_service/service/routers/api.py b/entities_service/service/routers/api.py index ee6e8d32..0080b54e 100644 --- a/entities_service/service/routers/api.py +++ b/entities_service/service/routers/api.py @@ -37,7 +37,7 @@ async def list_entities( "times - entities will be returned as an aggregated, flat list." ), ), - ] = [] # noqa: B006 + ] = [], # noqa: B006 ) -> list[dict[str, Any]]: """List all entities in the given namespace(s).""" # Format namespaces diff --git a/entities_service/service/security.py b/entities_service/service/security.py index d4e1364f..e4608a74 100644 --- a/entities_service/service/security.py +++ b/entities_service/service/security.py @@ -169,7 +169,7 @@ async def verify_user_access_token(token: str) -> tuple[bool, int | None, str | async def verify_token( - credentials: Annotated[HTTPAuthorizationCredentials, Depends(SECURITY_SCHEME)] + credentials: Annotated[HTTPAuthorizationCredentials, Depends(SECURITY_SCHEME)], ) -> None: """Verify a client user.""" credentials_exception = HTTPException( diff --git a/pyproject.toml b/pyproject.toml index 5aac6a10..ce185494 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,7 +42,7 @@ requires-python = "~=3.10" dynamic = ["version", "description"] dependencies = [ - "fastapi ~=0.115.6", + "fastapi ~=0.115.7", "httpx >=0.27.2,<1", "pydantic-settings ~=2.7", "pymongo ~=4.10", @@ -52,17 +52,17 @@ dependencies = [ [project.optional-dependencies] cli = [ - "httpx-auth ~=0.22.0", + "httpx-auth ~=0.23.1", "pyyaml ~=6.0", "typer ~=0.15.1", ] testing = [ "cryptography >=43.0.0,<45", # Pytest runs, end in Segmentation Fault for dlite-python versions >0.5.23 - "dlite-python <=0.5.23; python_version<'3.13'", # DLite is not yet compatible with Python 3.13 + "dlite-python <=0.5.23; python_version < '3.13'", # DLite is not yet compatible with Python 3.13 "mongomock ~=4.3", "pytest ~=8.3", - "pytest-asyncio ~=0.25.1", + "pytest-asyncio ~=0.25.2", "pytest-cov ~=6.0", "pytest-httpx >=0.34.0,<1", "entities-service[cli]", @@ -71,7 +71,7 @@ server = [ "gunicorn ~=23.0.0", ] dev = [ - "pre-commit ~=4.0", + "pre-commit ~=4.1", "entities-service[cli,testing]", ] diff --git a/tests/conftest.py b/tests/conftest.py index e1ba653c..db78300c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -493,7 +493,7 @@ def get_backend_user() -> GetBackendUserFixture: from entities_service.service.config import CONFIG def _get_backend_user( - auth_role: Literal["read", "write"] | None = None + auth_role: Literal["read", "write"] | None = None, ) -> UserDict: """Return the backend user for the given authentication role.""" if auth_role is None: @@ -763,7 +763,7 @@ def mock_auth_verification( mock_openid_config_call(base_url=str(CONFIG.oauth2_provider_base_url).rstrip("/")) def _mock_auth_verification( - auth_role: Literal["read", "write"] | None = None + auth_role: Literal["read", "write"] | None = None, ) -> None: """Mock authentication on the /_admin endpoints.""" if auth_role is None: diff --git a/tests/service/test_security.py b/tests/service/test_security.py index 1a775351..cca40036 100644 --- a/tests/service/test_security.py +++ b/tests/service/test_security.py @@ -475,7 +475,10 @@ async def test_verify_user_access_token_parse_error_user( assert await verify_user_access_token("mock_token") == (False, None, None) assert "Could not parse user info from GitLab provider." in caplog.messages - assert f"Response:\n{json.dumps({'invalid': 'response'})}" in caplog.messages + response = json.dumps( + {"invalid": "response"}, indent=0, separators=(",", ":") + ).replace("\n", "") + assert f"Response:\n{response}" in caplog.messages async def test_verify_user_access_token_parse_error_member( @@ -511,7 +514,10 @@ async def test_verify_user_access_token_parse_error_member( assert "Could not parse user info from GitLab provider." not in caplog.messages assert "Could not parse member role from GitLab provider." in caplog.messages - assert f"Response:\n{json.dumps({'invalid': 'response'})}" in caplog.messages + response = json.dumps( + {"invalid": "response"}, indent=0, separators=(",", ":") + ).replace("\n", "") + assert f"Response:\n{response}" in caplog.messages async def test_verify_user_access_token_is_called(