Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Apr 15, 2024
1 parent 9c65dd3 commit 839a2b9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 32 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
48 changes: 16 additions & 32 deletions src/typenv/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -171,8 +169,7 @@ def bytes(
encoding: Literal["hex"],
default: type[_Missing] | _Bytes = _Missing,
validate: Callable | Iterable[Callable] = (),
) -> _Bytes:
...
) -> _Bytes: ...

@typing.overload
def bytes(
Expand All @@ -182,8 +179,7 @@ def bytes(
encoding: Literal["hex"],
default: None,
validate: Callable | Iterable[Callable] = (),
) -> _Bytes | None:
...
) -> _Bytes | None: ...

def bytes(
self,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -342,8 +327,7 @@ def list(
default: None,
validate: Callable | Iterable[Callable] = (),
subcast: Callable[..., _T],
) -> _List[_T] | None:
...
) -> _List[_T] | None: ...

def list(
self,
Expand Down

0 comments on commit 839a2b9

Please sign in to comment.