# ABCReg

ABCReg adds `AnnotatedABC` and `AnnotatedABCMeta`, which provide additional interface checking at registration time to ensure that registered virtual and ordinary subclasses are valid.

Use ABCReg if you are designing a plugin API or any other interface that might be implemented by an end user.

## Defining the Interface

Use `AnnotatedABC` just like an ordinary `ABC`. Make sure to mark your API methods as abstract and provide type hints:

```Python
from abc import abstractmethod
from abcreg import AnnotatedABC

class Queryable(AnnotatedABC):
    @abstractmethod
    def query(self, **kwargs) -> str: ...
```

We recommend you use virtual inheritance:

```Python
@Queryable.register
class VirtualQueryProvider:
    def query(self, **kwargs) -> str:
        return "query result"

assert issubclass(VirtualQueryProvider, Queryable)
assert isinstance(VirtualQueryProvider(), Queryable)
```

But, regular inheritance will also work:

```Python
class QueryProvider(Queryable):
    def query(self, **kwargs) -> str:
        return "query result"

assert issubclass(QueryProvider, Queryable)
```

## Requirements and Usage

Requries Python `3.10+`. With UV, require with `uv add abcreg`.

## Development

Pre-build checks:
``
uv sync --all-groups
uv run ruff check --fix
uv run ruff format --preview
uv run mypy abcreg
```