Aliases with correct capitalization for built-in Python types.
Project description
btypes
Aliases with correct capitalization for built-in Python types.
PEP8 states that classes should have names in CamelCase.
However, all the built-in types are lower case: str
, bool
, int
, float
, list
, dict
, etc.
This library provides aliases for all these types that are capitalized correctly.
They are straightforward aliases and can be used exactly like the original types.
Install
Requires Python 3.9+.
pip install btypes
Examples
from btypes import Int, List, Str
def comma_list(lst: List[Int]) -> Str:
return ", ".join(Str(e) for e in lst)
def range_list(limit: Int) -> List[Int]:
return List(range(limit))
Also works with pattern matching:
from btypes import Bool, Str, Union
def print_type(x: Union[Bool, Str]) -> None:
match x:
case Bool():
print("a boolean")
case Str():
print("a string")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
btypes-4.0.1dev0.tar.gz
(6.7 kB
view hashes)
Built Distribution
Close
Hashes for btypes-4.0.1dev0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b25aff49e3b2a35621e02cb82bea52e175424f7db49d33119078110adf6fd79d |
|
MD5 | 32284814b92733f5c3ee6e3c6ecd9d71 |
|
BLAKE2b-256 | cc0cd2130e6294cb583ae70253094c005d66b6f6ac077d4d170fef3428afeda9 |