From 839a2b938b92f0c54992e6e7266e9737fd7b551e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 15 Apr 2024 17:46:55 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- README.md | 1 + src/typenv/__init__.py | 48 ++++++++++++++---------------------------- 2 files changed, 17 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 221fa17..b4f0b06 100644 --- a/README.md +++ b/README.md @@ -196,6 +196,7 @@ env = Env() # A single validator function NAME = env.str("NAME", validate=lambda n: n.startswith("Harry")) + # A validator function can signal error by raising an exception def is_positive(num): if num <= 0: diff --git a/src/typenv/__init__.py b/src/typenv/__init__.py index e707b39..cc30d73 100644 --- a/src/typenv/__init__.py +++ b/src/typenv/__init__.py @@ -145,14 +145,12 @@ def str( *, default: type[_Missing] | _Str = _Missing, validate: Callable | Iterable[Callable] = (), - ) -> _Str: - ... + ) -> _Str: ... @typing.overload def str( self, name: _Str, *, default: None, validate: Callable | Iterable[Callable] = () - ) -> _Str | None: - ... + ) -> _Str | None: ... def str( self, @@ -171,8 +169,7 @@ def bytes( encoding: Literal["hex"], default: type[_Missing] | _Bytes = _Missing, validate: Callable | Iterable[Callable] = (), - ) -> _Bytes: - ... + ) -> _Bytes: ... @typing.overload def bytes( @@ -182,8 +179,7 @@ def bytes( encoding: Literal["hex"], default: None, validate: Callable | Iterable[Callable] = (), - ) -> _Bytes | None: - ... + ) -> _Bytes | None: ... def bytes( self, @@ -202,14 +198,12 @@ def int( *, default: type[_Missing] | _Int = _Missing, validate: Callable | Iterable[Callable] = (), - ) -> _Int: - ... + ) -> _Int: ... @typing.overload def int( self, name: _Str, *, default: None, validate: Callable | Iterable[Callable] = () - ) -> _Int | None: - ... + ) -> _Int | None: ... def int( self, @@ -227,14 +221,12 @@ def bool( *, default: type[_Missing] | _Bool = _Missing, validate: Callable | Iterable[Callable] = (), - ) -> _Bool: - ... + ) -> _Bool: ... @typing.overload def bool( self, name: _Str, *, default: None, validate: Callable | Iterable[Callable] = () - ) -> _Bool | None: - ... + ) -> _Bool | None: ... def bool( self, @@ -252,14 +244,12 @@ def float( *, default: type[_Missing] | _Float = _Missing, validate: Callable | Iterable[Callable] = (), - ) -> _Float: - ... + ) -> _Float: ... @typing.overload def float( self, name: _Str, *, default: None, validate: Callable | Iterable[Callable] = () - ) -> _Float | None: - ... + ) -> _Float | None: ... def float( self, @@ -277,14 +267,12 @@ def decimal( *, default: type[_Missing] | D = _Missing, validate: Callable | Iterable[Callable] = (), - ) -> D: - ... + ) -> D: ... @typing.overload def decimal( self, name: _Str, *, default: None, validate: Callable | Iterable[Callable] = () - ) -> D | None: - ... + ) -> D | None: ... def decimal( self, @@ -314,14 +302,12 @@ def list( *, default: type[_Missing] | _List = _Missing, validate: Callable | Iterable[Callable] = (), - ) -> _List[_Str]: - ... + ) -> _List[_Str]: ... @typing.overload def list( self, name: _Str, *, default: None, validate: Callable | Iterable[Callable] = () - ) -> _List[_Str] | None: - ... + ) -> _List[_Str] | None: ... @typing.overload def list( @@ -331,8 +317,7 @@ def list( default: type[_Missing] | _List[_T] = _Missing, validate: Callable | Iterable[Callable] = (), subcast: Callable[..., _T], - ) -> _List[_T]: - ... + ) -> _List[_T]: ... @typing.overload def list( @@ -342,8 +327,7 @@ def list( default: None, validate: Callable | Iterable[Callable] = (), subcast: Callable[..., _T], - ) -> _List[_T] | None: - ... + ) -> _List[_T] | None: ... def list( self,