Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pre-commit.ci] pre-commit autoupdate #186

Merged
merged 2 commits into from
Oct 1, 2024
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
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.6.7
rev: v0.6.8
hooks:
- id: ruff
args:
Expand All @@ -60,7 +60,7 @@ repos:
# More information can be found in its documentation:
# https://bandit.readthedocs.io/en/latest/
- repo: https://github.com/PyCQA/bandit
rev: 1.7.9
rev: 1.7.10
hooks:
- id: bandit
args: ["-r"]
Expand Down
2 changes: 1 addition & 1 deletion entities_service/cli/_utils/generics.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def initialize_oauth2(
) from exc

try:
with httpx.Client() as client:
with httpx.Client(timeout=10) as client:
response: dict[str, Any] = client.get(openid_config_url).json()
except (httpx.HTTPError, JSONDecodeError) as exc:
raise ValueError(
Expand Down
4 changes: 2 additions & 2 deletions entities_service/cli/commands/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def namespaces(
] = False,
) -> list[str] | None:
"""List namespaces from the entities service."""
with httpx.Client(base_url=str(CONFIG.base_url)) as client:
with httpx.Client(base_url=str(CONFIG.base_url), timeout=10) as client:
try:
response = client.get("/_api/namespaces")
except httpx.HTTPError as exc:
Expand Down Expand Up @@ -183,7 +183,7 @@ def entities(
# and/or the "core" namespace (None)
specific_namespaces = [_get_specific_namespace(ns) for ns in target_namespaces]

with httpx.Client(base_url=str(CONFIG.base_url)) as client:
with httpx.Client(base_url=str(CONFIG.base_url), timeout=10) as client:
try:
response = client.get(
"/_api/entities",
Expand Down
2 changes: 1 addition & 1 deletion entities_service/cli/commands/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def login(
] = False,
) -> None:
"""Login to the entities service."""
with httpx.Client(base_url=str(CONFIG.base_url)) as client:
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:
Expand Down
4 changes: 3 additions & 1 deletion entities_service/cli/commands/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,9 @@ def upload(
raise typer.Exit()

# Upload entities
with httpx.Client(base_url=str(CONFIG.base_url), auth=oauth) as client:
with httpx.Client(
base_url=str(CONFIG.base_url), auth=oauth, timeout=10
) as client:
try:
response = client.post("/_admin/create", json=successes)
except httpx.HTTPError as exc:
Expand Down
2 changes: 1 addition & 1 deletion entities_service/cli/commands/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ def validate(
break

# Check if entity exists at its given URL URI
with httpx.Client(follow_redirects=True) as client:
with httpx.Client(follow_redirects=True, timeout=10) as client:
try:
response = client.get(get_uri(entity_model))
except httpx.HTTPError as exc:
Expand Down
7 changes: 4 additions & 3 deletions entities_service/service/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

async def get_openid_config() -> OpenIDConfiguration:
"""Get the OpenID configuration."""
async with AsyncClient() as client:
async with AsyncClient(timeout=10) as client:
error = False
try:
response = await client.get(
Expand All @@ -60,7 +60,7 @@ async def get_openid_config() -> OpenIDConfiguration:

async def verify_user_access_token(token: str) -> tuple[bool, int | None, str | None]:
"""Verify a user-provided GitLab access token."""
client = AsyncClient(headers={"Authorization": f"Bearer {token}"})
client = AsyncClient(headers={"Authorization": f"Bearer {token}"}, timeout=10)
error = False

# Get current user
Expand Down Expand Up @@ -195,7 +195,8 @@ async def verify_token(

# Get the user info from the OAuth2 provider based on the current credentials
async with AsyncClient(
headers={"Authorization": f"{credentials.scheme} {credentials.credentials}"}
headers={"Authorization": f"{credentials.scheme} {credentials.credentials}"},
timeout=10,
) as client:
error = False
try:
Expand Down
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,7 @@ def _client(
return Client(
base_url=f"http://{host}:{port}",
headers=auth_header,
timeout=10,
)

return _client