Skip to content

Commit

Permalink
fix: support custom fields for classes injection (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lancetnik authored Dec 14, 2023
1 parent 5fdb947 commit 9270d65
Show file tree
Hide file tree
Showing 13 changed files with 111 additions and 95 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ on:
- main
paths:
- docs/**
pull_request:
types: [opened, synchronize]

permissions:
contents: write
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
pydantic-version: ["pydantic-v1", "pydantic-v2"]
fail-fast: false

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ from fast_depends import inject
from fast_depends.library import CustomField

class Header(CustomField):
def use(self, **kwargs: AnyDict) -> AnyDict:
def use(self, /, **kwargs: AnyDict) -> AnyDict:
kwargs = super().use(**kwargs)
kwargs[self.param_name] = kwargs["headers"][self.param_name]
return kwargs
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ from fast_depends import inject
from fast_depends.library import CustomField

class Header(CustomField):
def use(self, **kwargs: AnyDict) -> AnyDict:
def use(self, /, **kwargs: AnyDict) -> AnyDict:
kwargs = super().use(**kwargs)
kwargs[self.param_name] = kwargs["headers"][self.param_name]
return kwargs
Expand Down
2 changes: 1 addition & 1 deletion docs/docs_src/advanced/custom/class_declaration.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from fast_depends.library import CustomField

class Header(CustomField):
def use(self, **kwargs):
def use(self, /, **kwargs):
kwargs = super().use(**kwargs)
kwargs[self.param_name] = kwargs["headers"][self.param_name]
return kwargs
2 changes: 1 addition & 1 deletion docs/docs_src/advanced/custom/starlette.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from starlette.routing import Route

class Path(CustomField):
def use(self, *, request, **kwargs):
def use(self, /, *, request, **kwargs):
return {
**super().use(request=request, **kwargs),
self.param_name: request.path_params.get(self.param_name)
Expand Down
2 changes: 1 addition & 1 deletion fast_depends/__about__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""FastDepends - extracted and cleared from HTTP domain FastAPI Dependency Injection System"""

__version__ = "2.2.4"
__version__ = "2.2.5"
Loading

0 comments on commit 9270d65

Please sign in to comment.