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")
FAQs
Why require Python 3.9 as the minimum version?
Because Python 3.9 introduced generic collections in the standard library: list[int], dict[str, float];
and the whole point of btypes is that you can use the same identifier as constructor and as type annotation.
Metadata
Release files for btypes 4.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| btypes-4.1.1.tar.gz | 6.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| btypes-4.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.7 kB
Release files / btypes-4.1.1.tar.gz
| Download URL | btypes-4.1.1.tar.gz |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e714a134667e49a6f149f076ead3925c92018ea43ce6c251954444fd7cf6afd2
|
|
BLAKE2b-256 checksum How to use checksums |
fd8bc6ff683fd24c064243da895379212642c5ce3124ad2563cbdc89850ae843
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.12 CPython/3.7.11 Linux/5.15.15-76051515-generic
|
Release files / btypes-4.1.1-py3-none-any.whl
| Download URL | btypes-4.1.1-py3-none-any.whl |
|---|---|
| Size | 6.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
15609ea6fbee4c3c6ff1bdf2461b038075999ebecaed228b5683fd72f053b03b
|
|
BLAKE2b-256 checksum How to use checksums |
f585382a0c8494e12b5a7e701a059764e6ae55564717ba0f0fd5604aa12f8316
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.12 CPython/3.7.11 Linux/5.15.15-76051515-generic
|