You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 5, 2022. It is now read-only.
Currently Settings.__init__ uses assert to make sure value or type_hint are not given as arguments:
def__init__(self, **kwargs):
assert (
'value'notinkwargs
), '"value" argument should not be passed to Settings.__init__()'assert (
'type_hint'notinkwargs
), '"type_hint" argument should not be passed to Settings.__init__()'
I think it would be better to explicitly raise an exception (either ValueError or better, some more specific one) if illegal arguments are passed.
I like how assert is used generously in the library as a defensive programming technique, but it's better not to use it in the public API. Assertions are stripped when running with higher optimization levels (e.g. -O or -OO), so, if the user passes some illegal arguments, no exception may be thrown at the point where the check was supposed to be made, making it harder to debug what went wrong.
The text was updated successfully, but these errors were encountered:
@jmp thank you very much for reporting the issue. Yes, the initial idea was that assertions are there for development time only. I think you are right, it should always be there, no matter the optimization level and should be an explicit exception.
Currently
Settings.__init__
usesassert
to make surevalue
ortype_hint
are not given as arguments:I think it would be better to explicitly raise an exception (either
ValueError
or better, some more specific one) if illegal arguments are passed.I like how
assert
is used generously in the library as a defensive programming technique, but it's better not to use it in the public API. Assertions are stripped when running with higher optimization levels (e.g.-O
or-OO
), so, if the user passes some illegal arguments, no exception may be thrown at the point where the check was supposed to be made, making it harder to debug what went wrong.The text was updated successfully, but these errors were encountered: