Skip to main content

a class decorator that applies to all methods

Project description

decorate-all-methods

Decorator that applies a decorator to all methods of a class.

Installing

pip install decorate-all-methods

Example Usage

from decorate_all_methods import decorate_all_methods
from tenacity import retry, stop_after_attempt, wait_fixed


@decorate_all_methods(retry(stop=stop_after_attempt(3), wait=wait_fixed(1)), exclude=['__init__'])
class MyClass(object):

    def __init__(self, object):
        """Will not be retried."""
        pass

    def force_error(self):
        """Will be retried 3 times."""
        assert False

    def force_another_error(self):
        """Will also be retried 3 times."""
        assert False

Note: It is not necessary to exclude any methods.

Versioning

We use SemVer for versioning.

License

This project is licensed under the Apache License, Version 2.0.

Acknowledgments

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for decorate-all-methods, version 0.0.2
Filename, size File type Python version Upload date Hashes
Filename, size decorate-all-methods-0.0.2.tar.gz (1.8 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page