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 registerer

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.2.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: registerer-0.2.2.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.2.tar.gz
Algorithm Hash digest
SHA256 fee9d63b8561951031ddf1b600fb99ad3ab75d68292a436a7933663ae395d699
MD5 f1ede06ff8db4a51337ce72651fb47e5
BLAKE2b-256 47d14b655d3b3d6ff8557f7c31e8c0c87ff18f6e39a9f1ec06f40d4afb1b4b47

See more details on using hashes here.

File details

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

File metadata

  • Download URL: registerer-0.2.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 82c4a5936d1af69bbaa487e57e2b045b634abb4904cac48fb11d8ba4956ff856
MD5 568c28731de0b77faa23ddcc7a0cea7b
BLAKE2b-256 13a74d954b0ac1d13edcfa693eb7526e121ff18b4bc567f2fd660982618dc762

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