Metadata-Version: 2.4
Name: abcreg
Version: 0.1.0
Summary: Add your description here
License-Expression: MIT
License-File: LICENSE
Requires-Python: >=3.13
Description-Content-Type: text/markdown

# 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:

```
from abc import abstractmethod
from abcreg import AnnotatedABC

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

We recommend you use virtual inheritance:

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

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

But, regular inheritance will also work:

```
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`.
