Skip to main content

overrides

https://api.travis-ci.org/mkorpela/overrides.svg https://coveralls.io/repos/mkorpela/overrides/badge.svg https://img.shields.io/pypi/v/overrides.svg http://pepy.tech/badge/overrides

A decorator to automatically detect mismatch when overriding a method. See http://stackoverflow.com/questions/1167617/in-python-how-do-i-indicate-im-overriding-a-method

All checks are done when a class or a method is created and not when a method is executed or an instance of a class is created. This means that performace implications are minimal.

Installation

$ pip install overrides

Usage

from overrides import overrides

class SuperClass(object):

    def method(self):
        """This is the doc for a method and will be shown in subclass method too!"""
        return 2

class SubClass(SuperClass):

    @overrides
    def method(self):
        return 1

Enforcing usage

from overrides import EnforceOverrides, final, overrides

class SuperClass(EnforceOverrides):

    @final
    def method(self):
        """This is the doc for a method and will be shown in subclass method too!"""
        return 2

    def method2(self):
        """This is the doc for a method and will be shown in subclass method too!"""
        return 2

    def method3(self):
        """This is the doc for a method and will be shown in subclass method too!"""
        return 2

# THIS FAILS
class SubClass1(SuperClass):

    def method(self): # <-- overriding a final method
        return 1


# THIS FAILS
class SubClass2(SuperClass):

    def method2(self): # <-- @overrides decorator missing
        return 1

# THIS ONE IS OK
class SubClass3(SuperClass):

    @overrides
    def method2(self):
        return 1

Metadata

Release files for overrides 2.7.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 overrides 2.7.0
File Size Uploaded Provenance Actions
overrides-2.7.0.tar.gz 4.5 kB Without provenance Details for overrides-2.7.0.tar.gz

Release files / overrides-2.7.0.tar.gz

Download URL overrides-2.7.0.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
d8532646879a1e2bb20eb0e21d135d2bf7cac2f843e9b71b53ae2447c62c33e4
BLAKE2b-256 checksum
How to use checksums
ac982430afd204c48ac0a529d439d7e22df8fa603c668d03456b5947cb59ec36
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.40.1 CPython/3.7.3

Security for overrides 2.7.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.

Release history Release notifications | RSS feed

This release

2.7.0 This release

1 release file No provenance

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