Skip to main content

Tiny beartype helper lib for inline type assertion and narrowing (not affiliated)

Project description

bearcheck

Tiny extension to beartype, which allows inline type assertion and narrowing similar to check_type from typeguard.

Using bearcheck() is faster and safer than check_type(), since it leverages the incredibly fast beartype library for type checking, and allows specifying the exact return type.

Usage

from bearcheck import bearcheck, Check

var = bearcheck("a", Check[Literal["a", "b"]])
reveal_type(var)  # Type of "var" is "Literal['a', 'b']"

.. as opposed to ..

from typeguard import check_type

var = check_type("a", Literal["a", "b"])
reveal_type(var)  # Type of "var" is "Any"

type_check() returns Any if the type hint is not primitive, a common pitfall!

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

bearcheck-0.1.4.tar.gz (1.5 kB view details)

Uploaded Source

Built Distribution

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

bearcheck-0.1.4-py3-none-any.whl (2.4 kB view details)

Uploaded Python 3

File details

Details for the file bearcheck-0.1.4.tar.gz.

File metadata

  • Download URL: bearcheck-0.1.4.tar.gz
  • Upload date:
  • Size: 1.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for bearcheck-0.1.4.tar.gz
Algorithm Hash digest
SHA256 93e124efc42192a58efc10b2f14771d47aa4889a095dbb6338a66168ed10ab13
MD5 989228232faaaba1b84c2e1fcc68e702
BLAKE2b-256 b933cb6a5bcef67e5b2a766a07ed2a1d79f32975c10a02d8bcde3bf29ac708bf

See more details on using hashes here.

File details

Details for the file bearcheck-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: bearcheck-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 2.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for bearcheck-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a40e4c761bd020f2bc9da9a85352c950c3e25540a70c43e15f513a93492dfbee
MD5 3499471f8e1236a64b3ba4e3e44972a7
BLAKE2b-256 93b8bbc850ad8ec4f6944317b299450072c6f2c7fa3a7531ca1c9ba067498187

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