Skip to content

Commit

Permalink
🐛 Undesired print statements
Browse files Browse the repository at this point in the history
  • Loading branch information
migduroli committed Nov 6, 2024
1 parent 49d9cae commit bd9c824
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
6 changes: 4 additions & 2 deletions examples/add_models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import logging

import flama
from flama import Flama, Route

Expand All @@ -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


Expand Down
2 changes: 0 additions & 2 deletions flama/authentication/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
4 changes: 1 addition & 3 deletions flama/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)):
Expand Down
4 changes: 2 additions & 2 deletions flama/resources/crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 3 additions & 1 deletion tests/schemas/test_data_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
2 changes: 1 addition & 1 deletion tests/schemas/test_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down

0 comments on commit bd9c824

Please sign in to comment.