{"id":16367315,"url":"https://github.com/mortymacs/abcmeta","last_synced_at":"2025-03-16T15:32:48.841Z","repository":{"id":40574885,"uuid":"380959314","full_name":"mortymacs/abcmeta","owner":"mortymacs","description":"Python meta class and abstract method library with restrictions.","archived":false,"fork":false,"pushed_at":"2024-06-12T07:34:09.000Z","size":40,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-12T02:49:34.005Z","etag":null,"topics":["abc","abcmeta","abstractclass","abstractmethod","oop","python","python3"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/abcmeta/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mortymacs.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-28T08:24:54.000Z","updated_at":"2024-06-12T07:34:13.000Z","dependencies_parsed_at":"2024-06-12T09:58:42.247Z","dependency_job_id":"fe8fd40f-35f7-4bd6-9ca3-878392c4c605","html_url":"https://github.com/mortymacs/abcmeta","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mortymacs%2Fabcmeta","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mortymacs%2Fabcmeta/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mortymacs%2Fabcmeta/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mortymacs%2Fabcmeta/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mortymacs","download_url":"https://codeload.github.com/mortymacs/abcmeta/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221665566,"owners_count":16860280,"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":["abc","abcmeta","abstractclass","abstractmethod","oop","python","python3"],"created_at":"2024-10-11T02:49:36.502Z","updated_at":"2024-10-27T10:51:20.647Z","avatar_url":"https://github.com/mortymacs.png","language":"Python","readme":"# abcmeta\n[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/mortymacs/abcmeta/python-test.yml?style=flat-square)](https://github.com/mortymacs/abcmeta/actions/workflows/python-test.yml)\n[![PyPi version](https://img.shields.io/pypi/v/abcmeta?style=flat-square)](https://pypi.org/project/abcmeta)\n[![PyPI pyversions](https://img.shields.io/pypi/pyversions/abcmeta?style=flat-square)](https://pypi.python.org/pypi/abcmeta/)\n[![PyPI download month](https://img.shields.io/pypi/dm/abcmeta?style=flat-square)](https://pypi.python.org/pypi/abcmeta/)\n\nPython meta class and abstract method library with restrictions.\n\nThis library provides a restricted way to validate abstract methods.\nThe Python's default abstract method library only validates the methods\nthat exist in the derived classes and nothing else.\nWhat this library provides is apart from that validation it provides\nvalidations over the method's signature.\nAll you need is to import `ABCMeta` and `abstractmethod` from this library.\n\nIt works on both annotations and without annotations methods.\n\n### Installation\n\nYou can install the package by `pip`:\n\n```bash\n$ pip install abcmeta\n```\n\n\u003e Note: abcmeta supports Python3.6+.\n\n### Quick start\n\n```python\nfrom typing import Dict, Text\n\nfrom abcmeta import ABC, abstractmethod\n\n\nclass Base(ABC):\n    @abstractmethod\n    def method_2(self, name: Text, age: int) -\u003e Dict[Text, Text]:\n        \"\"\"Abstract method.\"\"\"\n\n    @abstractmethod\n    def method_3(self, name, age):\n        \"\"\"Abstract method.\"\"\"\n\nclass Drived(Base):\n    def method_2(self, name: Text, age: int) -\u003e Dict[Text, Text]:\n        return {\"name\": \"test\"}\n\n    def method_3(self, name, age):\n        pass\n```\n\nIf you put a different signature, it will raise an error with 'diff' format with hints about what you've missed:\n\n```python\nclass Drived(Base):\n    def method_2(self, name: Text, age: int) -\u003e List[Text]:\n        return {\"name\": \"test\"}\n```\n\nAnd it will raise:\n\n```python\nTraceback (most recent call last):\n  File \"/Workspaces/test.py\", line 41, in \u003cmodule\u003e\n    class Drived(Base):\n  File \"/usr/lib/python3.9/abc.py\", line 85, in __new__\n    cls = super().__new__(mcls, name, bases, namespace, **kwargs)\n  File \"/abcmeta/__init__.py\", line 179, in __init_subclass__\n    raise AttributeError(\nAttributeError: Signature of the derived method is not the same as parent class:\n- method_2(self, name: str, age: int) -\u003e Dict[str, str]\n?                                        ^ ^     -----\n\n+ method_2(self, name: str, age: int) -\u003e List[str]\n?                                        ^ ^\n\nDerived method expected to return in 'typing.Dict[str, str]' type, but returns 'typing.List[str]'\n```\n\nFor different parameter names:\n\n```python\nclass Drived(Base):\n    def method_2(self, username: Text, age: int) -\u003e List[Text]:\n        return {\"name\": \"test\"}\n```\n\nAnd it will raise:\n\n```python\nTraceback (most recent call last):\n  File \"/Workspaces/test.py\", line 41, in \u003cmodule\u003e\n    class Drived(Base):\n  File \"/usr/lib/python3.9/abc.py\", line 85, in __new__\n    cls = super().__new__(mcls, name, bases, namespace, **kwargs)\n  File \"/abcmeta/__init__.py\", line 180, in __init_subclass__\n    raise AttributeError(\nAttributeError: Signature of the derived method is not the same as parent class:\n- method_2(self, name: str, age: int) -\u003e Dict[str, str]\n+ method_2(self, username: str, age: int) -\u003e Dict[str, str]\n?                ++++\n\nDerived method expected to get name paramter, but gets username\n```\n\n### Issue\n\nIf you're faced with a problem, please file an [issue](https://github.com/mortymacs/abcmeta/issues/new) on Github.\n\n\n### Contribute\n\nYou're always welcome to contribute to the project! Please file an issue and send your great PR.\n\n### Support\n\nIf you find this project useful and want to support its development, consider [buying me a coffee!](https://buymeacoffee.com/mortymacs)\n\n### License\n\nPlease read the [LICENSE](./LICENSE) file.\n","funding_links":["https://buymeacoffee.com/mortymacs"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmortymacs%2Fabcmeta","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmortymacs%2Fabcmeta","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmortymacs%2Fabcmeta/lists"}