Skip to main content

Build Status Coverage Status PyPI version PyPI license

Python polymorphic function declaration with obvious syntax. Just use the same function name and mark each function definition with @polymorphic decorator.

Installation

pip install polypie

Requirements

  • Python 3.5+

  • typeguard (will be installed automatically)

Example

from typing import Any, Sequence

from polypie import polymorphic, PolypieException


@polymorphic
def example(a: int, b):
    print('(1)')


@polymorphic
def example(a: str, b: Any):
    print('(2)')


@polymorphic
def example(a: Sequence[str]):
    print('(3)')


example(100, 200)   # (1)
example('foo', 200)   # (2)
example(['foo'])   # (3)
example(('bar', 'baz'))   # (3)
try:
    example({'foo': 'bar'})
except PolypieException as exc:
    print(exc)   # Matching signature <...> not found


class Example:

    def __init__(self):
        self.values = {}

    @polymorphic
    def value(self, name):
        return self.values[name]

    @polymorphic
    def value(self, name, value):
        self.values[name] = value


instance = Example()
instance.value('foo', 100)
instance.value('bar', 'baz')
print(instance.value('foo'))   # 100
print(instance.value('bar'))   # baz

Tests

tox [-e ENV] [-- --cov]

Metadata

Release files for polypie 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for polypie 0.2.0
File Size Uploaded Provenance Actions
polypie-0.2.0.tar.gz 3.7 kB Without provenance Details for polypie-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for polypie 0.2.0
File Interpreter ABI Platform Actions
polypie-0.2.0-py3-none-any.whl Python 3 none any Details for polypie-0.2.0-py3-none-any.whl

Total release size: 7.5 kB

Release files / polypie-0.2.0.tar.gz

Download URL polypie-0.2.0.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
07acea8578cdb4b533d724297b3d6739b0d146cc3b004b2b7efd387b9b83f2bd
BLAKE2b-256 checksum
How to use checksums
755d71d481fc92cbf87000060b84bd9de534a6f163609ac6ea72b8f783bb3023
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.1

Release files / polypie-0.2.0-py3-none-any.whl

Download URL polypie-0.2.0-py3-none-any.whl
Size 3.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e8c584f2d60fe82586e08a9aed9e6c427b6d2b95538b4b441500b5ab3ba99508
BLAKE2b-256 checksum
How to use checksums
6678ca281335f50d4981646be33d671d6b83bc2095ea291d2e00f40053c49714
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.1

Security for polypie 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page