[bug] Lazy validation fails with TypeError: __call__() takes 2 positional arguments but 3 were given
See original GitHub issueDescribe the bug Tried to introduce Lazy Validators as described in https://www.dynaconf.com/validation/#computed-values i.e.
from dynaconf.utils.parse_conf import empty, Lazy
Validator("FOO", default=Lazy(empty, formatter=my_function))
First bug (documentation): The above fails with
ImportError: cannot import name 'empty' from 'dynaconf.utils.parse_conf'
–> “empty” seems to be now in dynaconf.utils.functional.empty
Second bug:
Lazy Validator fails with
TypeError: __call__() takes 2 positional arguments but 3 were given
To Reproduce Steps to reproduce the behavior:
from dynaconf.utils.parse_conf import Lazy
from dynaconf.utils.functional import empty
def lazy_foobar(s, v):
return "foobar"
from dynaconf import Dynaconf
s = Dynaconf(
validators=[Validator("FOOBAR", default=Lazy(empty, formatter=lazy_foobar)),],
)
print(s.FOOBAR)
stacktrace:
print(s.FOOBAR)
File "c:\ta\virtualenv\dconf\lib\site-packages\dynaconf\base.py", line 113, in __getattr__
self._setup()
File "c:\ta\virtualenv\dconf\lib\site-packages\dynaconf\base.py", line 164, in _setup
settings_module=settings_module, **self._kwargs
File "c:\ta\virtualenv\dconf\lib\site-packages\dynaconf\base.py", line 236, in __init__
only=self._validate_only, exclude=self._validate_exclude
File "c:\ta\virtualenv\dconf\lib\site-packages\dynaconf\validator.py", line 417, in validate
validator.validate(self.settings, only=only, exclude=exclude)
File "c:\ta\virtualenv\dconf\lib\site-packages\dynaconf\validator.py", line 198, in validate
settings, settings.current_env, only=only, exclude=exclude
File "c:\ta\virtualenv\dconf\lib\site-packages\dynaconf\validator.py", line 227, in _validate_items
if callable(self.default)
TypeError: __call__() takes 2 positional arguments but 3 were given
Expected behavior Work as documented in https://www.dynaconf.com/validation/#computed-values
Environment (please complete the following information):
- OS: Windows 10 Pro
- Dynaconf Version: 3.1.7 (also 3.1.4)
- Frameworks in use: N/A
Additional context Add any other context about the problem here.
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Python TypeError takes 2 positional arguments but 3 are given
This code is supposed to calculate the shortest Manhattan distance between a node state (character position) and the nearest food location.
Read more >[CT-672] _relations_cache_for_schemas() takes 2 positional ...
First time install of DBT (dbt-postgres) on Ubuntu. ... Log files don't seem to give hints on the cause of the error. How...
Read more >pydantic validator __init__() takes exactly 1 positional ...
I see a type error, when I try to use it as is in the training code. pydantic.main.BaseModel.__init__ TypeError: __init__() takes exactly 1...
Read more >Error in keras when trying to recreate example from website
Error in py_call_impl(callable, dots$args, dots$keywords) : TypeError: update() takes from 2 to 3 positional arguments but 4 were given.
Read more >How to solve the error? ' __init__() takes 2 positional ...
' __init__() takes 2 positional arguments but 3 were given'. I have an assignment to create a regression model for a given datasets....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @GibranHL0
My suggestions
on
utils/parse_conf.py
Then, update the documentation on https://www.dynaconf.com/validation/#computed-values (docs/validation.md)
the correct way of using the computed lazy value must be
Hi 👋
I’d like to be assigned to this issue and give it a try.