Skip to content

2.2.6

Compare
Choose a tag to compare
@Lancetnik Lancetnik released this 15 Dec 16:23
· 75 commits to main since this release
d525e8a

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