Skip to content

awdjc/tyd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

tyd

Typing essentials that make the development process a bit faster.

New: Optional support.

from tyd import *  # demo purposes only

value: Optional[str] = "Hello!"
nothing: Optional[str] = None

unwrap(value)
unwrap(nothing)  # raises an error because this is None

unwrap_or(value)  # "Hello!"
unwrap_or(nothing, "Hello again")  # "Hello again"

unwrap_or_else(nothing, lambda: str(10 + 10))  # "20"

# map() essentially transforms the data to another if it's not None
map(value, 100)  # 100 (int)
map(nothing, 100)  # None

# some other utilities
is_some(value)
is_none(nothing)

About

Typing utilities.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages