Skip to main content

Everything you need to implement maintainable and easy to use registry patterns in your project.

Project description

Fast Registry

Everything you need to implement maintainable and easy to use registry patterns in your project.

Installation

pip install fast-registry

Register Classes

Register classes with the same interface, enforce the type check and enjoy the benefits of type hints:

from registerer import Registerer


class Animal:
    def talk(self) -> None:
        raise NotImplementedError


# create a registry that requires registered items to implement the Animal interface:
animal_registry = Registerer(Animal)


@animal_registry.register("dog")
class Dog(Animal):
    def talk(self) -> None:
        return "woof"

Register Functions

Register functions and benefit from the function annotations validator (optional):

from registerer import Registerer, FunctionAnnotationValidator

database_registry = Registerer(
    validators=[
        FunctionAnnotationValidator(annotations=[("name", str)]),
    ]
)

@database_registry.register("sqlite")
def sqlite_database_connection(name: str):
    return f"sqlite connection {name}"

Create Custom Validators

By Creating a subclass of RegistryValidator, you can create your own validators to check registered classes/functions if you need to.

Examples

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

registerer-0.2.1.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

registerer-0.2.1-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file registerer-0.2.1.tar.gz.

File metadata

  • Download URL: registerer-0.2.1.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.10.4 Linux/5.17.5-arch1-1

File hashes

Hashes for registerer-0.2.1.tar.gz
Algorithm Hash digest
SHA256 75b4c8220806d31771be927b6ab9dd766a45012d6e29b7dd76843b759628b918
MD5 0215b8162fada9778ddcda0bad71933c
BLAKE2b-256 f5f44a70bc28a0fc18a6398218f50b3ff4bc3701656cd4650c840de8838dfde8

See more details on using hashes here.

File details

Details for the file registerer-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: registerer-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.10.4 Linux/5.17.5-arch1-1

File hashes

Hashes for registerer-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7051231fb7b1c32e49d1795ab3028e59da08332e3ba235bd6281be60140d64d6
MD5 dab9ba060ae501fd36d5f7278a4fd824
BLAKE2b-256 af1b95ac10b2a9de7d0f8db2ac5b22ec84c6b3b1615642e3925edc714fffe025

See more details on using hashes here.

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