Skip to content

Commit

Permalink
Update optional argument type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
nkantar committed Aug 26, 2024
1 parent cfd3492 commit 7b3d81c
Showing 1 changed file with 14 additions and 20 deletions.
34 changes: 14 additions & 20 deletions src/parsenvy/parsenvy.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import builtins
from os import getenv
from typing import Any, List, Optional, Set, Tuple
from typing import Any, List, Set, Tuple


TRUES = ["true", "1"]
Expand All @@ -16,8 +16,8 @@

def bool(
env_var: builtins.str,
default: Optional[builtins.bool] = None,
) -> Optional[builtins.bool]:
default: builtins.bool | None = None,
) -> builtins.bool | None:
"""
Parse environment variable value into a boolean.
Expand Down Expand Up @@ -46,8 +46,8 @@ def bool(

def int(
env_var: builtins.str,
default: Optional[builtins.int] = None,
) -> Optional[builtins.int]:
default: builtins.int | None = None,
) -> builtins.int | None:
"""
Parse environment variable value into a integer.
Expand All @@ -73,8 +73,8 @@ def int(

def float(
env_var: builtins.str,
default: Optional[builtins.float] = None,
) -> Optional[builtins.float]:
default: builtins.float | None = None,
) -> builtins.float | None:
"""
Parse environment variable value into a float.
Expand All @@ -98,16 +98,13 @@ def float(
)


def list(
env_var: builtins.str,
default: Optional[List[Any]] = None,
) -> Optional[List[Any]]:
def list(env_var: builtins.str, default: List[Any] | None = None) -> List[Any] | None:
"""
Parse environment variable value into a list.
Args:
env_var (str): Name of desired environment variable.
default (List, optional): Optional fallback value.
default (list, optional): Optional fallback value.
Returns:
List (optional): Environment variable typecast into a list.
Expand All @@ -123,8 +120,8 @@ def list(

def tuple(
env_var: builtins.str,
default: Optional[Tuple[Any, ...]] = None,
) -> Optional[Tuple[Any, ...]]:
default: Tuple[Any, ...] | None = None,
) -> Tuple[Any, ...] | None:
"""
Parse environment variable value into a tuple.
Expand All @@ -145,10 +142,7 @@ def tuple(
return builtins.tuple(value.split(","))


def set(
env_var: builtins.str,
default: Optional[Set[Any]] = None,
) -> Optional[Set[Any]]:
def set(env_var: builtins.str, default: Set[Any] | None = None) -> Set[Any] | None:
"""
Parse environment variable value into a set.
Expand All @@ -171,8 +165,8 @@ def set(

def str(
env_var: builtins.str,
default: Optional[builtins.str] = None,
) -> Optional[builtins.str]:
default: builtins.str | None = None,
) -> builtins.str | None:
"""
Parse environment variable value into a str.
Expand Down

0 comments on commit 7b3d81c

Please sign in to comment.