lint: app.api passes pylint

This commit is contained in:
Iain Learmonth 2024-11-16 19:57:10 +00:00
parent 3610707495
commit 3b223f2c1a

View file

@ -71,7 +71,7 @@ def validate_marker(marker_str: str) -> int:
abort(400, description="Marker must be a valid token.")
TLPMarkings = Union[
TLPMarkings = Union[ # pylint: disable=invalid-name
Literal["default"],
Literal["clear"],
Literal["green"],
@ -81,9 +81,10 @@ TLPMarkings = Union[
]
def list_resources(
def list_resources( # pylint: disable=too-many-arguments,too-many-locals
model: Type[Any],
serialize_func: Callable[[Any], Dict[str, Any]],
*,
filters: Optional[List[ListFilter]] = None,
order_by: Optional[ColumnElement[Any]] = None,
resource_name: str = 'ResourceList',
@ -130,7 +131,7 @@ def list_resources(
response[resource_name]["NextMarker"] = next_marker
return jsonify(response)
except Exception:
except Exception: # pylint: disable=broad-exception-caught
logger.exception("An unexpected error occurred")
abort(500)
@ -138,8 +139,8 @@ def list_resources(
@api.route('/web/group', methods=['GET'])
def list_groups() -> ResponseReturnValue:
return list_resources(
model=Group,
serialize_func=lambda group: group.to_dict(),
Group,
lambda group: group.to_dict(),
resource_name='OriginGroupList',
max_allowed_items=MAX_ALLOWED_ITEMS,
protective_marking='amber',
@ -167,8 +168,8 @@ def list_origins() -> ResponseReturnValue:
abort(400, description="GroupId must be a valid integer.")
return list_resources(
model=Origin,
serialize_func=lambda origin: origin.to_dict(),
Origin,
lambda origin: origin.to_dict(),
filters=filters,
resource_name='OriginsList',
max_allowed_items=MAX_ALLOWED_ITEMS,
@ -198,8 +199,8 @@ def list_mirrors() -> ResponseReturnValue:
filters.append(Proxy.destroyed.is_not(None))
return list_resources(
model=Proxy,
serialize_func=lambda proxy: proxy.to_dict(),
Proxy,
lambda proxy: proxy.to_dict(),
filters=filters,
resource_name='MirrorsList',
max_allowed_items=MAX_ALLOWED_ITEMS,
@ -228,8 +229,8 @@ def list_onions() -> ResponseReturnValue:
abort(400, description="GroupId must be a valid integer.")
return list_resources(
model=Onion,
serialize_func=lambda onion: onion.to_dict(),
Onion,
lambda onion: onion.to_dict(),
filters=filters,
resource_name='OnionsList',
max_allowed_items=MAX_ALLOWED_ITEMS,