{"id":17136956,"url":"https://github.com/un-def/polypie","last_synced_at":"2025-04-13T09:25:15.480Z","repository":{"id":57464717,"uuid":"60840165","full_name":"un-def/polypie","owner":"un-def","description":"Python polymorphic functions done right","archived":false,"fork":false,"pushed_at":"2019-05-21T08:36:18.000Z","size":22,"stargazers_count":18,"open_issues_count":1,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-22T04:18:37.906Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/un-def.png","metadata":{"files":{"readme":"README.rst","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":"2016-06-10T10:29:42.000Z","updated_at":"2020-12-07T07:24:14.000Z","dependencies_parsed_at":"2022-08-31T03:11:14.874Z","dependency_job_id":null,"html_url":"https://github.com/un-def/polypie","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/un-def%2Fpolypie","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/un-def%2Fpolypie/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/un-def%2Fpolypie/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/un-def%2Fpolypie/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/un-def","download_url":"https://codeload.github.com/un-def/polypie/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248690002,"owners_count":21146044,"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":[],"created_at":"2024-10-14T20:05:51.799Z","updated_at":"2025-04-13T09:25:15.454Z","avatar_url":"https://github.com/un-def.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"polypie\n=======\n\n|Build Status| |Coverage Status| |PyPI version| |PyPI license|\n\nPython polymorphic function declaration with obvious syntax. Just use\nthe same function name and mark each function definition with\n``@polymorphic`` decorator.\n\nInstallation\n~~~~~~~~~~~~\n\n``pip install polypie``\n\nRequirements\n~~~~~~~~~~~~\n\n-  Python 3.5+\n-  `typeguard \u003chttps://github.com/agronholm/typeguard\u003e`__ (will be installed automatically)\n\nExample\n~~~~~~~\n\n.. code:: python\n\n    from typing import Any, Sequence\n\n    from polypie import polymorphic, PolypieException\n\n\n    @polymorphic\n    def example(a: int, b):\n        print('(1)')\n\n\n    @polymorphic\n    def example(a: str, b: Any):\n        print('(2)')\n\n\n    @polymorphic\n    def example(a: Sequence[str]):\n        print('(3)')\n\n\n    example(100, 200)   # (1)\n    example('foo', 200)   # (2)\n    example(['foo'])   # (3)\n    example(('bar', 'baz'))   # (3)\n    try:\n        example({'foo': 'bar'})\n    except PolypieException as exc:\n        print(exc)   # Matching signature \u003c...\u003e not found\n\n\n    class Example:\n\n        def __init__(self):\n            self.values = {}\n\n        @polymorphic\n        def value(self, name):\n            return self.values[name]\n\n        @polymorphic\n        def value(self, name, value):\n            self.values[name] = value\n\n\n    instance = Example()\n    instance.value('foo', 100)\n    instance.value('bar', 'baz')\n    print(instance.value('foo'))   # 100\n    print(instance.value('bar'))   # baz\n\nTests\n~~~~~\n\n``tox [-e ENV] [-- --cov]``\n\n.. |Build Status| image:: https://travis-ci.org/un-def/polypie.svg?branch=master\n   :target: https://travis-ci.org/un-def/polypie\n.. |Coverage Status| image:: https://coveralls.io/repos/github/un-def/polypie/badge.svg?branch=master\n   :target: https://coveralls.io/github/un-def/polypie?branch=master\n.. |PyPI version| image:: https://badge.fury.io/py/polypie.svg\n   :target: https://pypi.python.org/pypi/polypie/\n.. |PyPI license| image:: https://img.shields.io/pypi/l/polypie.svg?maxAge=3600\n   :target: https://raw.githubusercontent.com/un-def/polypie/master/LICENSE\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fun-def%2Fpolypie","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fun-def%2Fpolypie","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fun-def%2Fpolypie/lists"}