Skip to content
Merged
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
9 changes: 6 additions & 3 deletions tests/unit/app/endpoints/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ async def test_config_endpoint_handler_configuration_not_loaded(mocker):
)
auth = ("test_user", "token", {})
with pytest.raises(HTTPException) as exc_info:
await config_endpoint_handler(auth=auth, request=request)

await config_endpoint_handler(
auth=auth, request=request # pyright:ignore[reportArgumentType]
)
Comment on lines +29 to +31
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

🧩 Analysis chain

Prefer fixing the auth type over suppressing Pyright.

Use the shared MOCK_AUTH (or cast to AuthTuple) so we can drop the ignore. Then remove the suppression.

Apply this diff after correcting the auth value above:

-        await config_endpoint_handler(
-            auth=auth, request=request  # pyright:ignore[reportArgumentType]
-        )
+        await config_endpoint_handler(
+            auth=auth, request=request
+        )

Example options (pick one):

  • If a shared constant exists:
    from tests.unit.utils.auth_helpers import MOCK_AUTH
    auth = MOCK_AUTH
  • Or with typing:
    from typing import cast

    Replace with the actual import path for AuthTuple

    from app..types import AuthTuple
    auth = cast(AuthTuple, ("mock_user_id", "mock_username", False, "mock_token"))

Verify where MOCK_AUTH/AuthTuple live:

As per coding guidelines


🏁 Script executed:

#!/bin/bash
rg -nP --type=py -C3 '\bMOCK_AUTH\s*='
rg -nP --type=py -C3 '\bAuthTuple\b'

Length of output: 22349


🏁 Script executed:

#!/bin/bash
# Check shared auth_helpers for MOCK_AUTH
if [ -f tests/unit/utils/auth_helpers.py ]; then
  sed -n '1,200p' tests/unit/utils/auth_helpers.py
else
  echo "File tests/unit/utils/auth_helpers.py not found."
fi

Length of output: 978


Remove Pyright suppression by casting auth to AuthTuple.

Import cast and AuthTuple, wrap the auth argument in cast(AuthTuple, auth), then drop the # pyright:ignore[reportArgumentType].

Example diff:

-from typing import cast
-from authentication.interface import AuthTuple
+from typing import cast
+from authentication.interface import AuthTuple

 await config_endpoint_handler(
-    auth=auth, request=request  # pyright:ignore[reportArgumentType]
+    auth=cast(AuthTuple, auth),
+    request=request
 )

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In tests/unit/app/endpoints/test_config.py around lines 29 to 31, replace the
pyright suppression by importing cast and AuthTuple at the top of the file and
wrapping the auth argument with cast(AuthTuple, auth) when calling
config_endpoint_handler; then remove the trailing "#
pyright:ignore[reportArgumentType]" comment. Ensure the imports are added (e.g.,
from typing import cast and the module that provides AuthTuple) and the auth
parameter is passed as cast(AuthTuple, auth).

assert exc_info.value.status_code == status.HTTP_500_INTERNAL_SERVER_ERROR
assert exc_info.value.detail["response"] == "Configuration is not loaded"

Expand Down Expand Up @@ -73,6 +74,8 @@ async def test_config_endpoint_handler_configuration_loaded(mocker):
}
)
auth = ("test_user", "token", {})
response = await config_endpoint_handler(auth=auth, request=request)
response = await config_endpoint_handler(
auth=auth, request=request # pyright:ignore[reportArgumentType]
)
assert response is not None
assert response == cfg.configuration
Loading