Skip to main content

Aliases with correct capitalization for built-in Python types.

Project description


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.


Requires Python 3.9+.

pip install btypes


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")


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.

Project details

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.1.1.tar.gz (6.8 kB view hashes)

Uploaded source

Built Distribution

btypes-4.1.1-py3-none-any.whl (6.9 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page