Skip to content

Commit

Permalink
chore: bump dependencies (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lancetnik authored Jun 6, 2024
1 parent afd278d commit d325108
Show file tree
Hide file tree
Showing 13 changed files with 82 additions and 74 deletions.
2 changes: 1 addition & 1 deletion docs/docs/tutorial/annotated.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func(user_id=1) # correct calling
!!! tip ""
I really recommend *do not use* `Annotated` as a positional argument

The best way to avoid all missunderstanding between you and Python - use `pydantic.Field` with `Annotated` everywhere
The best way to avoid all misunderstanding between you and Python - use `pydantic.Field` with `Annotated` everywhere

Like in the following example

Expand Down
3 changes: 2 additions & 1 deletion fast_depends/core/build.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import inspect
from copy import deepcopy
from typing import (
Any,
Awaitable,
Expand Down Expand Up @@ -97,7 +98,7 @@ def build_call_model(
if isinstance(next_custom, Depends):
dep = next_custom
elif isinstance(next_custom, CustomField):
custom = next_custom
custom = deepcopy(next_custom)
else: # pragma: no cover
raise AssertionError("unreachable")

Expand Down
4 changes: 2 additions & 2 deletions fast_depends/core/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def flat_dependencies(
flat: Dict[
Callable[..., Any],
Tuple[
"CallModel[..., Any]",
CallModel[..., Any],
Tuple[Callable[..., Any], ...],
],
] = {}
Expand Down Expand Up @@ -179,7 +179,7 @@ def __init__(
self.extra_dependencies = extra_dependencies or ()
self.custom_fields = custom_fields or {}

sorted_dep: List["CallModel[..., Any]"] = []
sorted_dep: List[CallModel[..., Any]] = []
flat = self.flat_dependencies
for calls in flat.values():
_sort_dep(sorted_dep, calls, flat)
Expand Down
3 changes: 2 additions & 1 deletion fast_depends/use.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
Callable,
Iterator,
Optional,
Protocol,
Sequence,
TypeVar,
Union,
cast,
overload,
)

from typing_extensions import ParamSpec, Protocol
from typing_extensions import ParamSpec

from fast_depends._compat import ConfigDict
from fast_depends.core import CallModel, build_call_model
Expand Down
2 changes: 1 addition & 1 deletion fast_depends/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def get_typed_signature(call: Callable[..., Any]) -> Tuple[inspect.Signature, An
def collect_outer_stack_locals() -> Dict[str, Any]:
frame = inspect.currentframe()

frames: List["FrameType"] = []
frames: List[FrameType] = []
while frame is not None:
if "fast_depends" not in frame.f_code.co_filename:
frames.append(frame)
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ dynamic = ["version"]
dependencies = [
"pydantic>=1.7.4,!=1.8,!=1.8.1,<3.0.0",
"anyio>=3.0.0,<5.0.0",
"typing-extensions<4.12.1; python_version < '3.9'",
]

[project.urls]
Expand Down
4 changes: 2 additions & 2 deletions requirements.dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
-r requirements.test.txt

mypy >=1.8.0
ruff ==0.4.4
codespell ==2.2.6
ruff ==0.4.8
codespell ==2.3.0
2 changes: 1 addition & 1 deletion scripts/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ echo "Running mypy..."
mypy fast_depends

echo "Running ruff linter (isort, flake, pyupgrade, etc. replacement)..."
ruff fast_depends tests --fix
ruff check fast_depends tests --fix

echo "Running ruff formatter (black replacement)..."
ruff format tests
Expand Down
3 changes: 1 addition & 2 deletions tests/async/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ async def dep(a: str):


@inject(pydantic_config={"str_max_length" if PYDANTIC_V2 else "max_anystr_length": 1})
async def limited_str(a=Depends(dep)):
...
async def limited_str(a=Depends(dep)): ...


@inject()
Expand Down
15 changes: 15 additions & 0 deletions tests/library/test_custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,18 @@ def sync_catch(key: logging.Logger = Header(cast=False)): # noqa: B008
return key

assert sync_catch(headers={"key": 1}) == 1


def test_reusable_annotated() -> None:
HeaderKey = Annotated[float, Header(cast=False)]

@inject
def sync_catch(key: HeaderKey) -> float:
return key

@inject
def sync_catch2(key2: HeaderKey) -> float:
return key2

assert sync_catch(headers={"key": 1}) == 1
assert sync_catch2(headers={"key2": 1}) == 1
3 changes: 1 addition & 2 deletions tests/sync/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ def dep(a: str):


@inject(pydantic_config={"str_max_length" if PYDANTIC_V2 else "max_anystr_length": 1})
def limited_str(a=Depends(dep)):
...
def limited_str(a=Depends(dep)): ...


@inject()
Expand Down
12 changes: 4 additions & 8 deletions tests/test_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,16 @@


def test_params():
def func1(m):
...
def func1(m): ...

def func2(c, b=Depends(func1), d=CustomField()): # noqa: B008
...

def func3(b):
...
def func3(b): ...

def main(a, b, m=Depends(func2), k=Depends(func3)):
...
def main(a, b, m=Depends(func2), k=Depends(func3)): ...

def extra_func(n):
...
def extra_func(n): ...

model = build_call_model(main, extra_dependencies=(Depends(extra_func),))

Expand Down
Loading

0 comments on commit d325108

Please sign in to comment.