Registry / testing / interface-meta

interface-meta

JSON →
library2.0.1pypypi✓ verified 23d ago

`interface_meta` is a Python library (current version 1.3.0) that provides a robust way to expose extensible APIs. It focuses on enforcing method signatures and ensuring consistent documentation for subclasses, making it suitable for plugin architectures. The library is currently in maintenance, with its last release in April 2022.

pip install interface-meta
INSTALL
IMPORT
SIG · INTERFACE-META
I
interface-meta
testingpythonv2.0.1
Install
1.5s avg
Import
54ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.0.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.056s · 17.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.5s · import 0.052s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

InterfaceMeta
from interface_meta import InterfaceMeta
from interface_meta.interface import InterfaceMeta
The primary metaclass `InterfaceMeta` is directly available under the top-level package.

This quickstart demonstrates defining an interface using `InterfaceMeta` with abstract properties and methods, and then creating a conforming implementation. It highlights how to set interface-specific configurations for method signature enforcement and documentation.

from abc import abstractproperty from interface_meta import InterfaceMeta class MyInterface(metaclass=InterfaceMeta): """An example interface.""" INTERFACE_EXPLICIT_OVERRIDES = True INTERFACE_RAISE_ON_VIOLATION = False INTERFACE_SKIPPED_NAMES = {'__init__'} def __init__(self): """MyInterface constructor.""" pass @abstractproperty def name(self): """A descriptive name.""" raise NotImplementedError def say_hello(self): """Say hello.""" return f"Hello, I am {self.name}!" class MyImplementation(MyInterface): def __init__(self): super().__init__() self._name = "My Implementation" @property def name(self): return self._name # Example usage: instance = MyImplementation() print(instance.say_hello()) print(f"Instance name: {instance.name}")
Debug
Known issues
gotchaThe library heavily relies on metaclasses, which can be complex and might introduce unexpected behavior if not fully understood. Misuse or incorrect configuration of `InterfaceMeta` attributes (e.g., `INTERFACE_EXPLICIT_OVERRIDES`, `INTERFACE_RAISE_ON_VIOLATION`) can lead to subtle bugs or silent failures in API enforcement.
fix
Thoroughly review the `InterfaceMeta` configuration attributes (`INTERFACE_EXPLICIT_OVERRIDES`, `INTERFACE_RAISE_ON_VIOLATION`, `INTERFACE_SKIPPED_NAMES`) to match desired enforcement strictness. Test interface implementations rigorously to ensure they adhere to the defined contracts. Consider enabling `INTERFACE_RAISE_ON_VIOLATION=True` during development for stricter checking.
affects: All versions
gotchaLimited official documentation might make it challenging to troubleshoot advanced usage or deeply understand internal mechanics beyond the provided examples. The GitHub README explicitly states 'full documentation will come at some point.'
fix
Rely on the examples in the GitHub repository and source code for detailed understanding. Be prepared to experiment and validate behavior through testing. Consult related projects or prior art mentioned in the README (e.g., `pure_interface`, `python-interface`) for conceptual guidance, though their implementations will differ.
affects: All versions
deprecatedThe library's last release was in April 2022, suggesting it is in maintenance mode rather than active development. While functional, it might not receive frequent updates for new Python features or community best practices.
fix
Be aware that new features or critical bug fixes may not be actively developed. Plan for potential internal modifications or consider alternative, more actively maintained interface enforcement libraries if long-term active development and bleeding-edge Python compatibility are paramount for your project.
affects: 1.3.0 and older
Errors
Common errors & fixes
TypeError: Can't instantiate abstract class MyAbstractClass with abstract method my_abstract_method
A class inheriting from an `interface_meta` InterfaceMeta-based interface (or standard `abc.ABC` which `interface_meta` is compatible with) was instantiated without implementing all of its abstract methods.
fix
Ensure that any concrete class inheriting from an interface defines all methods declared as abstract in the interface. For example, if `MyInterface` defines `my_abstract_method`, your subclass `MyImplementation` must provide an implementation for it.
TypeError: Method 'my_method' on class 'MyImplementation' does not conform to interface 'MyInterface': signature mismatch
A method in a subclass, intended to implement an interface method, has a different signature (e.g., incorrect number of arguments, different parameter names, or unexpected positional/keyword arguments) than the method defined in the `interface_meta` Interface.
fix
Adjust the method signature in the subclass (`MyImplementation.my_method`) to precisely match the signature defined in the parent interface (`MyInterface.my_method`), including parameters and their types if type hints are used. `interface-meta` allows additional *optional* arguments in subclasses, but required arguments must match.
ModuleNotFoundError: No module named 'interface_meta'
The `interface-meta` library is not installed in the Python environment, or there is a typo in the import statement.
fix
Install the library using pip: `pip install interface-meta` or correct the import statement to `from interface_meta import InterfaceMeta` (or other components as needed).
AttributeError: 'MyImplementation' object has no attribute 'some_property'
A subclass of an `interface-meta` InterfaceMeta-based interface is missing a required property or method defined in the interface, or there's a typo when accessing it.
fix
Ensure that the subclass explicitly defines all properties and methods declared in the interface. If the property is meant to be abstract, ensure it's properly implemented in the subclass.
Upgrade
Version history
2.0.1latest on PyPI · released Apr 30, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
Resources
interface-meta — pip install interface-meta · libregistry