diff --git a/examples/add_models.py b/examples/add_models.py index 3bb24500..a69b863d 100644 --- a/examples/add_models.py +++ b/examples/add_models.py @@ -1,3 +1,5 @@ +import logging + import flama from flama import Flama, Route @@ -7,13 +9,13 @@ class AppStatus: async def startup(): - print("\nStarting up the ML API...\n") + logging.info("\nStarting up the ML API...\n") # Here, whatever action we want to be run at the startup of the application AppStatus.loaded = True async def shutdown(): - print("\nShutting down the ML API...\n") + logging.info("\nShutting down the ML API...\n") # Here, whatever action we want to be run at the shutdown of the application diff --git a/flama/authentication/components.py b/flama/authentication/components.py index 0f021541..037a50b8 100644 --- a/flama/authentication/components.py +++ b/flama/authentication/components.py @@ -21,7 +21,6 @@ def __init__(self, secret: bytes, *, header_key: str, header_prefix: str, cookie self.cookie_key = cookie_key def _token_from_cookies(self, cookies: Cookies) -> bytes: - print(f"ERROR: {cookies}") try: token = cookies[self.cookie_key]["value"] except KeyError: @@ -31,7 +30,6 @@ def _token_from_cookies(self, cookies: Cookies) -> bytes: return token.encode() def _token_from_header(self, headers: Headers) -> bytes: - print(f"ERROR: {headers}") try: header_prefix, token = headers[self.header_key].split() except KeyError: diff --git a/flama/http.py b/flama/http.py index 79705154..97909bde 100644 --- a/flama/http.py +++ b/flama/http.py @@ -72,14 +72,12 @@ async def __call__( # type: ignore[override] class EnhancedJSONEncoder(json.JSONEncoder): def default(self, o): - if isinstance(o, (Path, os.PathLike)): + if isinstance(o, (Path, os.PathLike, uuid.UUID)): return str(o) if isinstance(o, (bytes, bytearray)): return o.decode("utf-8") if isinstance(o, enum.Enum): return o.value - if isinstance(o, uuid.UUID): - return str(o) if isinstance(o, (set, frozenset)): return list(o) if isinstance(o, (datetime.datetime, datetime.date, datetime.time)): diff --git a/flama/resources/crud.py b/flama/resources/crud.py index 938c2bd7..8fd0c1c0 100644 --- a/flama/resources/crud.py +++ b/flama/resources/crud.py @@ -194,8 +194,8 @@ async def partial_update( summary: Partially update a resource description: - Partially update a resource in this collection. Only the specified fields will be replaced, keeping the - rest, so no one is required. + Partially update a resource in this collection. Only the specified fields will be replaced, keeping the + rest, so no one is required. responses: 200: description: diff --git a/pyproject.toml b/pyproject.toml index 81eef2d3..d9e0f4f5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -123,7 +123,7 @@ skip_glob = [ [tool.ruff] line-length = 120 # Enable Pyflakes and pycodestyle rules. -select = ["E", "F"] +select = ["C90", "E", "F", "G", "I", "W", "T"] ignore = ["E721"] exclude = [ ".git", diff --git a/tests/schemas/test_data_structures.py b/tests/schemas/test_data_structures.py index 94b62eab..e04755ba 100644 --- a/tests/schemas/test_data_structures.py +++ b/tests/schemas/test_data_structures.py @@ -105,7 +105,9 @@ def test_json_schema(self): class TestCaseSchema: @pytest.fixture(scope="function") - def schema_type(self, app, request, foo_schema, bar_schema, bar_optional_schema, bar_list_schema, bar_dict_schema): + def schema_type( # noqa: C901 + self, app, request, foo_schema, bar_schema, bar_optional_schema, bar_list_schema, bar_dict_schema + ): if request.param is None: return None elif request.param == "bare_schema": diff --git a/tests/schemas/test_generator.py b/tests/schemas/test_generator.py index 2ed6dd1c..b56e143b 100644 --- a/tests/schemas/test_generator.py +++ b/tests/schemas/test_generator.py @@ -896,7 +896,7 @@ def schemas(self, owner_schema, puppy_schema, body_param_schema): return {"Owner": owner_schema, "Puppy": puppy_schema, "BodyParam": body_param_schema} @pytest.fixture(scope="function", autouse=True) - def add_endpoints(self, app, puppy_schema, body_param_schema): + def add_endpoints(self, app, puppy_schema, body_param_schema): # noqa: C901 @app.route("/endpoint/", methods=["GET"]) class PuppyEndpoint(HTTPEndpoint): async def get(self) -> types.Schema[puppy_schema.schema]: