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
I don't agree with TypeError for line 62 and 131. IMO TypeError should be be raised for programmatic errors when an incorrect type is used as function argument, e.g. in theory if we read a non str value from os.environ (which should never happen) . This is very different from typenv being unable to match the str to another type using its own set of parsing rules.
We could use custom types though for all the exceptions you mention. The reason we don't is because I couldn't think of a good reason to do so. Generally I think any exception from typenv is an error that should not be caught, as it means your env variables are bad. The variables should be fixed before trying again.
Custom exceptions only make sense if they are caught and handled. What's the use case for doing so?
Thanks for the lib, much cleaner & typed compared to environs
My only gripe is there are a bunch of places in the code where a generic exception is raised.
Would you be open to subclassing it and rasing specific exceptions instead?
This is my gut reaction looking at the code
https://github.com/hukkin/typenv/blob/master/src/typenv/__init__.py#L62 ->
TypeError
(std lib)https://github.com/hukkin/typenv/blob/master/src/typenv/__init__.py#L122 ->
MissingEnvironmentVariable
https://github.com/hukkin/typenv/blob/master/src/typenv/__init__.py#L131 ->
TypeError
(std lib)https://github.com/hukkin/typenv/blob/master/src/typenv/__init__.py#L413 ->
ValidationError
The text was updated successfully, but these errors were encountered: