Skip to content

Commit

Permalink
fix: misc linting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jjaakola-aiven committed Dec 9, 2024
1 parent 220f45d commit 0d6074c
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/karapace/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class AuthenticatorAndAuthorizer(AuthenticateProtocol, AuthorizeProtocol):
async def close(self) -> None:
...

async def start(self, stats: StatsClient) -> None:
async def start(self, stats: StatsClient) -> None: # pylint: disable=unused-argument
...


Expand Down
11 changes: 5 additions & 6 deletions src/karapace/forward_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ async def forward_request_remote(self, *, request: Request, primary_url: str) ->
status_code=response.status,
headers=response.headers,
)
else:
return PlainTextResponse(
content=await response.text(),
status_code=response.status,
headers=response.headers,
)
return PlainTextResponse(
content=await response.text(),
status_code=response.status,
headers=response.headers,
)
3 changes: 1 addition & 2 deletions src/karapace/rapu.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,7 @@ def __init__(
def _create_aiohttp_application(self, *, config: Config) -> aiohttp.web.Application:
if config.http_request_max_size:
return aiohttp.web.Application(client_max_size=config.http_request_max_size)
else:
return aiohttp.web.Application()
return aiohttp.web.Application()

async def close_by_app(self, app: aiohttp.web.Application) -> None: # pylint: disable=unused-argument
await self.close()
Expand Down
2 changes: 1 addition & 1 deletion src/schema_registry/middlewares/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async def set_content_types(request: Request, call_next):
if request.headers.get("Content-Type") == "application/octet-stream":
new_headers = request.headers.mutablecopy()
new_headers["Content-Type"] = "application/json"
request._headers = new_headers
request._headers = new_headers # pylint: disable=protected-access
request.scope.update(headers=request.headers.raw)

response = await call_next(request)
Expand Down
15 changes: 6 additions & 9 deletions src/schema_registry/routers/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,9 @@ async def config_put(
i_am_primary, primary_url = await schema_registry.get_master()
if i_am_primary:
return await controller.config_set(compatibility_level_request=compatibility_level_request)
elif not primary_url:
if not primary_url:
raise no_primary_url_error()
else:
return await forward_client.forward_request_remote(request=request, primary_url=primary_url)
return await forward_client.forward_request_remote(request=request, primary_url=primary_url)


@config_router.get("/{subject}")
Expand Down Expand Up @@ -92,10 +91,9 @@ async def config_set_subject(
i_am_primary, primary_url = await schema_registry.get_master()
if i_am_primary:
return await controller.config_subject_set(subject=subject, compatibility_level_request=compatibility_level_request)
elif not primary_url:
if not primary_url:
raise no_primary_url_error()
else:
return await forward_client.forward_request_remote(request=request, primary_url=primary_url)
return await forward_client.forward_request_remote(request=request, primary_url=primary_url)


@config_router.delete("/{subject}")
Expand All @@ -115,7 +113,6 @@ async def config_delete_subject(
i_am_primary, primary_url = await schema_registry.get_master()
if i_am_primary:
return await controller.config_subject_delete(subject=subject)
elif not primary_url:
if not primary_url:
raise no_primary_url_error()
else:
return await forward_client.forward_request_remote(request=request, primary_url=primary_url)
return await forward_client.forward_request_remote(request=request, primary_url=primary_url)
6 changes: 3 additions & 3 deletions src/schema_registry/routers/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""

from dependency_injector.wiring import inject, Provide
from fastapi import APIRouter, Depends
from fastapi import APIRouter, Depends, Query
from karapace.auth import AuthenticatorAndAuthorizer, User
from schema_registry.container import SchemaRegistryContainer
from schema_registry.routers.requests import SchemaListingItem, SchemasResponse, SubjectVersion
Expand Down Expand Up @@ -44,15 +44,15 @@ async def schemas_get(
schema_id: str, # TODO: type to actual type
includeSubjects: bool = False, # TODO: include subjects?
fetchMaxId: bool = False, # TODO: fetch max id?
format: str = "",
format_serialized: str = Query("", alias="format"),
authorizer: AuthenticatorAndAuthorizer = Depends(Provide[SchemaRegistryContainer.karapace_container.authorizer]),
controller: KarapaceSchemaRegistryController = Depends(Provide[SchemaRegistryContainer.schema_registry_controller]),
) -> SchemasResponse:
return await controller.schemas_get(
schema_id=schema_id,
include_subjects=includeSubjects,
fetch_max_id=fetchMaxId,
format_serialized=format,
format_serialized=format_serialized,
user=user,
authorizer=authorizer,
)
Expand Down
10 changes: 4 additions & 6 deletions src/schema_registry/routers/subjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,9 @@ async def subjects_subject_delete(
i_am_primary, primary_url = await schema_registry.get_master()
if i_am_primary:
return await controller.subject_delete(subject=subject, permanent=permanent)
elif not primary_url:
if not primary_url:
raise no_primary_url_error()
else:
return await forward_client.forward_request_remote(request=request, primary_url=primary_url)
return await forward_client.forward_request_remote(request=request, primary_url=primary_url)


@subjects_router.post("/{subject}/versions")
Expand Down Expand Up @@ -165,10 +164,9 @@ async def subjects_subject_version_delete(
i_am_primary, primary_url = await schema_registry.get_master()
if i_am_primary:
return await controller.subject_version_delete(subject=subject, version=version, permanent=permanent)
elif not primary_url:
if not primary_url:
raise no_primary_url_error()
else:
return await forward_client.forward_request_remote(request=request, primary_url=primary_url)
return await forward_client.forward_request_remote(request=request, primary_url=primary_url)


@subjects_router.get("/{subject}/versions/{version}/schema")
Expand Down

0 comments on commit 0d6074c

Please sign in to comment.