Skip to main content

Bitwise support for configuration

Project description

BitAware

Bitwise Toolbox

python ruff pytest markdown License: GPLv3

Usage

Define

from bitaware import BitFlag, BitAware

class PermissionTypes(BitFlag):
    ADMIN = 1
    USER = 2
    GUEST = 4
    MODERATOR = 8

class UserPermission(BitAware[PermissionTypes]):
    def __init__(self, value: int):
        super().__init__(value, PermissionTypes)
    pass

Use

Standalone:

permission = UserPermission(PermissionTypes.ADMIN | PermissionTypes.USER)

print(permission.has(PermissionTypes.ADMIN))  # True
print(permission.has(PermissionTypes.GUEST))  # False

As Pydantic field:

class User(BaseModel):
    permissions: UserPermission

Test

uv run pytest

Security

If you discover any security-related issues, please email email instead of using the issue tracker.


Copyright (c) 2025 Wojciech Nowicki

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

bitaware-0.1.1.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

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

bitaware-0.1.1-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file bitaware-0.1.1.tar.gz.

File metadata

  • Download URL: bitaware-0.1.1.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for bitaware-0.1.1.tar.gz
Algorithm Hash digest
SHA256 1a1c2ea396a568c45a7e15d255b7a87bddc94781e6d8ca2ae5e4db73e9abda7e
MD5 af5f23b287937a6a60bb0ccab0c214c3
BLAKE2b-256 736527440ccef778905ee82848c22082a3da725d0d6d17ac983d654b754e7e0f

See more details on using hashes here.

Provenance

The following attestation bundles were made for bitaware-0.1.1.tar.gz:

Publisher: publish.yml on wnowicki/bitaware

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bitaware-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: bitaware-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for bitaware-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0ad474c9b1178ee17f86ed899bc0966bae5f184b5419db11529150b4863a4171
MD5 b6eb20b7518596fe9570e37e209ff949
BLAKE2b-256 bfc0637927d3c5024fd0a83dd5c8a2812042ca36b1f65eb86fa4c01282be5704

See more details on using hashes here.

Provenance

The following attestation bundles were made for bitaware-0.1.1-py3-none-any.whl:

Publisher: publish.yml on wnowicki/bitaware

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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