{"id":15442091,"url":"https://github.com/lig/python-interfaces","last_synced_at":"2025-10-08T18:04:08.391Z","repository":{"id":57471830,"uuid":"183982548","full_name":"lig/python-interfaces","owner":"lig","description":"A new approach to interfaces in Python","archived":false,"fork":false,"pushed_at":"2022-12-08T05:03:40.000Z","size":47,"stargazers_count":15,"open_issues_count":4,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-06T12:12:46.288Z","etag":null,"topics":["interface","interfaces","python","python3","python37","python38"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lig.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-04-29T01:57:06.000Z","updated_at":"2024-11-14T22:53:13.000Z","dependencies_parsed_at":"2023-01-24T12:00:15.797Z","dependency_job_id":null,"html_url":"https://github.com/lig/python-interfaces","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lig%2Fpython-interfaces","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lig%2Fpython-interfaces/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lig%2Fpython-interfaces/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lig%2Fpython-interfaces/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lig","download_url":"https://codeload.github.com/lig/python-interfaces/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248550619,"owners_count":21122934,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["interface","interfaces","python","python3","python37","python38"],"created_at":"2024-10-01T19:25:06.930Z","updated_at":"2025-10-08T18:04:03.372Z","avatar_url":"https://github.com/lig.png","language":"Python","readme":"# Python Strict Interfaces\n\n\n## Installation\n\n```shell\npip install strict-interfaces\n```\n\n\n## Design Goals\n\n* Be as strict as possible\n* Fail on import time\n* Do not mess with `object` and/or `type` inheritance\n* Possibility to integrate in CPython Core\n* Ability to use \"out of the box\" regardless support in an interpreter\n\n\n## Features\n\n* Special keyword `implements` on the class definition\n* Multiple interface implementation\n* Implicit interface implementation\n* Interface inheritance with overloading being restricted\n* Special `isimplementation` function similar to `issubclass`\n* Partial `issubclass` support (see below)\n* It's restricted to create an interface instance\n* It's restricted to inherit from `object` and `interface` at the same time\n\n\n## Usage\n\n### Explicit implementation\n\n```python\nclass TestInterface(interfaces.interface):\n    def method(self, arg: typeT1) -\u003e typeT2:\n        pass\n\nclass TestClass(interfaces.object, implements=[TestInterface]):\n    def method(self, arg: typeT1) -\u003e typeT2:\n        pass\n```\n\n### Raises when is not implemented \n\n```python\nclass TestInterface(interfaces.interface):\n    def method(self, arg):\n        pass\n\nclass TestClass(interfaces.object, implements=[TestInterface]):\n    pass\n```\n\n### Implicit implementation and run-time check\n\n```python\nclass TestInterfaceA(interfaces.interface):\n    def method_a(arg: typeT1) -\u003e typeT1:\n        pass\n\nclass TestInterfaceB(interfaces.interface):\n    def method_b(arg: typeT2) -\u003e typeT2:\n        pass\n\nclass TestClass:\n    def method_a(arg: typeT1) -\u003e typeT1:\n        pass\n\n    def method_b(arg: typeT2) -\u003e typeT2:\n        pass\n\nassert interfaces.isimplementation(TestClass, (TestInterfaceA, TestInterfaceB))\n```\n\n### `isimplementation` checks whether all interfaces are implemented \n\n```python\nclass TestInterfaceA(interfaces.interface):\n    def method_a(arg: typeT1) -\u003e typeT1:\n        pass\n\nclass TestInterfaceB(interfaces.interface):\n    def method_b(arg: typeT2) -\u003e typeT2:\n        pass\n\nclass TestClass:\n    def method_a(arg: typeT1) -\u003e typeT1:\n        pass\n\n# NOTE: In this case `isimplementation` behaves different than `issubclass`\nassert not interfaces.isimplementation(TestClass, (TestInterfaceA, TestInterfaceB))\nassert issubclass(TestClass, (TestInterfaceA, TestInterfaceB))\n```\n\n\n## Contributing\n\nPull requests, feature requests, and bug reports are always welcome!\n\n[github.com/lig/python-interfaces](https://github.com/lig/python-interfaces)\n\n\n## Discussions\n\nThere are threads [on Python Ideas mailing list](https://groups.google.com/forum/#!topic/python-ideas/uZqje5A1Mcs) and [on Reddit](https://www.reddit.com/r/Python/comments/bkwtnp/a_new_approach_to_interfaces_in_python/).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flig%2Fpython-interfaces","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flig%2Fpython-interfaces","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flig%2Fpython-interfaces/lists"}