Skip to content

Commit d8e1a73

Browse files
refactor(contrib): cleanup code and add proper formatting( #27)
* refactor(redis): inherit from redis.asyncio.Redis to expose all commands * chore(contrib): remove granian dependency and add tortoise-orm support - Remove granian>=1.2.0 from project and dev dependencies - Add tortoise-orm>=0.20.0 to all dependencies - Update Redis test mocks to use execute_command instead of execute - Replace json_get/json_set mocks with standard get/set methods - Add json() sync method mock helper to redis_client fixture - Simplify mocked methods list in test fixtures - Remove unnecessary mock assertions in close() and json operation tests * refactor(contrib): cleanup code and add proper formatting
1 parent 196536a commit d8e1a73

93 files changed

Lines changed: 2186 additions & 1931 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

nexios_contrib/accepts/__init__.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,40 @@
44
This module provides content negotiation and Accept header processing
55
for Nexios applications.
66
"""
7+
78
from __future__ import annotations
9+
10+
from .dependency import AcceptsDepend
811
from .helpers import (
912
AcceptItem,
10-
parse_accept_header,
11-
parse_accept_language,
12-
parse_accept_charset,
13-
parse_accept_encoding,
14-
negotiate_content_type,
15-
negotiate_language,
16-
negotiate_charset,
17-
negotiate_encoding,
18-
matches_media_type,
19-
get_best_match,
20-
get_accepts_info,
13+
AcceptsInfo,
2114
create_vary_header,
22-
get_accepted_content_types,
23-
get_accepted_languages,
2415
get_accepted_charsets,
16+
get_accepted_content_types,
2517
get_accepted_encodings,
18+
get_accepted_languages,
19+
get_accepts_from_request,
20+
get_accepts_info,
2621
get_best_accepted_content_type,
2722
get_best_accepted_language,
28-
get_accepts_from_request,
29-
AcceptsInfo,
30-
23+
get_best_match,
24+
matches_media_type,
25+
negotiate_charset,
26+
negotiate_content_type,
27+
negotiate_encoding,
28+
negotiate_language,
29+
parse_accept_charset,
30+
parse_accept_encoding,
31+
parse_accept_header,
32+
parse_accept_language,
3133
)
3234
from .middleware import (
3335
Accepts,
34-
3536
AcceptsMiddleware,
3637
ContentNegotiationMiddleware,
3738
StrictContentNegotiationMiddleware,
3839
)
39-
from .dependency import AcceptsDepend
40+
4041
__all__ = [
4142
"AcceptItem",
4243
"parse_accept_header",

nexios_contrib/accepts/dependency.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,20 @@
44
This module provides dependency injection utilities for accessing
55
parsed Accept header information from requests.
66
"""
7-
from __future__ import annotations
8-
9-
from typing import Any
10-
from nexios.dependencies import Depend, Context
11-
from nexios.http import Request
12-
from .helpers import AcceptsInfo
137

8+
from __future__ import annotations
9+
from typing import cast
1410

1511

12+
from nexios.dependencies import Context, Depend
13+
from nexios.http import Request
1614

15+
from .helpers import AcceptsInfo
1716

1817

19-
def get_accepts_info_from_request(request: Request, attribute_name: str = "accepts") -> AcceptsInfo:
18+
def get_accepts_info_from_request(
19+
request: Request, attribute_name: str = "accepts"
20+
) -> AcceptsInfo:
2021
"""
2122
Get AcceptsInfo object from request.
2223
@@ -54,7 +55,9 @@ async def get_users(
5455
accepted_types = accepts.get_accepted_types()
5556
return {"accepted_types": accepted_types}
5657
"""
58+
5759
def _wrap(request: Request = Context().request) -> AcceptsInfo:
5860
return get_accepts_info_from_request(request, attribute_name)
5961

60-
return Depend(_wrap)
62+
return cast(AcceptsInfo, Depend(_wrap))
63+

0 commit comments

Comments
 (0)