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

Undesired print statements #155

Merged
merged 1 commit into from
Nov 6, 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
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
Loading