Skip to content

Releases: Lancetnik/FastDepends

2.4.1

25 Feb 14:26
cebf0b0
Compare
Choose a tag to compare

What's Changed

  • chore: remove optional dependencies, fix typos by @Lancetnik in #73

Full Changelog: 2.4.0...2.4.1

2.4.0

20 Feb 05:28
90d4f87
Compare
Choose a tag to compare

What's Changed

  • Add fast_depends.shema.get_schema method to generate wrapped function payload (close #6)
  • Improve ForwardRef resolution
  • Update copyrights
  • Update Readme and docs to close #59
  • build(deps-dev): bump ruff from 0.1.11 to 0.1.13 by https://github.com/dependabot in #60
  • release: 2.4.0 by @Lancetnik in #61

Full Changelog: 2.3.1...0.2.4

0.2.4b0

15 Jan 17:41
9e44f6f
Compare
Choose a tag to compare

What's Changed

  • Add fast_depends.shema.get_schema method to generate wrapped function payload (close #6)
  • Improve ForwardRef resolution
  • Update copyrights
  • Update Readme and docs to close #59
  • build(deps-dev): bump ruff from 0.1.11 to 0.1.13 by @dependabot in #60
  • release: 2.4.0 by @Lancetnik in #61

Waiting for FastStream update to release stable version

Full Changelog: 2.3.1...0.2.4b0

2.3.1

10 Jan 16:53
Compare
Choose a tag to compare

Correct model.flat_params calculation

Full Changelog: 2.3.0...2.3.1

2.3.0

09 Jan 18:29
114c463
Compare
Choose a tag to compare

What's Changed

  • Multiple Annotated arguments support:
    from typing import Annotated
    from annotated_types import Ge
    from pydantic.functional_validators import AfterValidator
    
    @inject()
    def f(a: Annotated[int, Ge(10), AfterValidator(lambda x: x + 10)]) -> int:
        return a
    
    assert f(10) == 20
  • Support correct Generator annotation
    @inject
     def simple_func(a: str) -> Iterator[int]:
         for _ in range(2):
             yield a
    
     for i in simple_func("1"):
         assert i == 1
  • solve async dependencies without subdependencies in parallel tasks
  • solve CustomField with async use_field in parallel
  • build(deps-dev): bump ruff from 0.1.9 to 0.1.11 by @dependabot in #56
  • get rid of protected objects by @VitailOG in #57
  • feat: parallel dependencies resolving by @Lancetnik in #58

New Contributors

Full Changelog: 2.2.8...2.3.0

2.2.8

22 Dec 20:26
Compare
Choose a tag to compare

Restore fast_depends._compat.CreateBaseModel to save FastStream<0.3.7 compatibility

Full Changelog: 2.2.7...2.2.8

2.2.7

22 Dec 14:55
458e8f1
Compare
Choose a tag to compare

What's Changed

  • bugfix: correct yield overriding by @Lancetnik in #50
    from fast_depends import inject, Depends, dependency_provider
    
    def dep1():
        yield 1
    
    def dep2():
        yield 2
    
    @inject()
    def func(d = Depends(dep1)):
        return d
    
    assert func() == 1
    
    with dependency_provider.scope(dep1, dep2):
        assert func() == 2
  • build(deps): bump actions/download-artifact from 3 to 4 by @dependabot in #44
  • build(deps-dev): bump black from 23.11.0 to 23.12.0 by @dependabot in #48
  • build(deps-dev): bump isort from 5.13.0 to 5.13.2 by @dependabot in #47
  • build(deps): bump dawidd6/action-download-artifact from 2.28.0 to 3.0.0 by @dependabot in #45
  • build(deps-dev): bump ruff from 0.1.7 to 0.1.8 by @dependabot in #46
  • build(deps): bump actions/upload-artifact from 3 to 4 by @dependabot in #43

Full Changelog: 2.2.6...2.2.7

2.2.6

15 Dec 16:23
d525e8a
Compare
Choose a tag to compare

What's Changed

Provides you with the ability to setup pydantic config using @inject

@inject(pydantic_config={"str_max_length": 8})
def limited_str(a: str):
    ...
 
limited_str("*" * 9)  # raises ValidationError

Also, added context manager method to override dependencies:

from fast_depends import Depends, dependency_provider, inject

def base_dep():
    return 1

def override_dep():
    return 2

@inject
def func(d=Depends(base_dep)):
    return d

with dependency_provider.scope(base_dep, override_dep):
    assert func() == 2

assert func() == 1

Full Changelog: 2.2.5...2.2.6

2.2.5

14 Dec 17:27
9270d65
Compare
Choose a tag to compare

What's Changed

New CustomField syntax to support classes injection:

class Header(CustomField):
    def use(
        self,
        /,  # <- new thing
        **kwargs
    ):
        kwargs = super().use(**kwargs)
        kwargs[self.param_name] = kwargs["headers"][self.param_name]
        return kwargs
  • docs: fix typo by @Lancetnik in #36
  • fix: support custom fields for classes injection by @Lancetnik in #39
  • chore: drop python3.7 support

Full Changelog: 2.2.4...2.2.5

2.2.4

13 Dec 19:24
13ba7b7
Compare
Choose a tag to compare

What's Changed

Now you can use FastDepends to inject dependencies to your class constructors and/or methods!

from fast_depends import Depends, inject

def get_var():
    return 1

class Class:
    @inject
    def __init__(self, a = Depends(get_var)) -> None:
        self.a = a

    @inject
    def calc(self, a = Depends(get_var)) -> int:
        return a + self.a

assert Class().calc() == 2

Full Changelog: 2.2.3...2.2.4