Skip to main content

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

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.

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.0.1b1.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

btypes-4.0.1b1-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file btypes-4.0.1b1.tar.gz.

File metadata

  • Download URL: btypes-4.0.1b1.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.0a2 CPython/3.7.11 Linux/5.15.4-201.fc35.x86_64

File hashes

Hashes for btypes-4.0.1b1.tar.gz
Algorithm Hash digest
SHA256 015a364c72e07e87f58ea7fdaa74c44d339d33a451e5cc1905fe93ad591c991b
MD5 2c84bd772ecfa8f82518adbf41586298
BLAKE2b-256 b422236e09fe169f1b4b9bfb963c29b9ee45dfc197d202b35221ec2c1541bfb4

See more details on using hashes here.

File details

Details for the file btypes-4.0.1b1-py3-none-any.whl.

File metadata

  • Download URL: btypes-4.0.1b1-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.0a2 CPython/3.7.11 Linux/5.15.4-201.fc35.x86_64

File hashes

Hashes for btypes-4.0.1b1-py3-none-any.whl
Algorithm Hash digest
SHA256 3f4b2354ec8fb0a88943718d23bd731708140e00e34c963783beb4db6f52ea67
MD5 e608f13c9219d2f1bab244d747017d32
BLAKE2b-256 c4f0df97d70cd8cfb700b4f86db077b42fa678c0eb01da626ca2275b640cfa82

See more details on using hashes here.

Supported by

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