Skip to main content

build status

accrocchio

Accrocchio is a library to mark and being notified of smelly code (a.k.a, “accrocchio”).

Example

from accrocchio.badgeofshame import accrocchio
from accrocchio import observers


class AClassThatSmells(metaclass=accrocchio):
    pass

@accrocchio
def a_function_that_smells():
    pass


accrocchio.how_many()     # here we have 1, as you have declared a smelly class
AClassThatSmells()
accrocchio.how_many()     # here we have 2, as you have created an instance of a smelly class
a_function_that_smells()
accrocchio.how_many()     # here we have 3, as you have invoked a smelly function

accrocchio.reset()
accrocchio.how_many()     # here we have 0

# You can also be notified of smelly code execution, such as:

class MyAccrocchioObserver(observers.AccrocchioObserver):
    def on_accrocchio(self):
        print('Another accrocchio!')

    def reset(self):
        print('Reset accrocchi')
accrocchio.add_observer(MyAccrocchioObserver())
a_function_that_smells()   # prints 'Another accrocchio!'
accrocchio.reset()         # prints 'Reset accrocchi'

It is also possible to decorate the entire class. Both the declaration and the instantiation of such classes increase the accrocchio counters.

from accrocchio.badgeofshame import accrocchio
from accrocchio import observers


@accrocchio
class AClassThatSmells:
    pass


accrocchio.how_many()     # here we have 1, as you have declared a smelly class
AClassThatSmells()
accrocchio.how_many()     # here we have 2, as you have created an instance of a smelly class

You might declare an accrocchio using type hinting, as follows:

from accrocchio.badgeofshame import accrocchio, detonator


def f(a: detonator[int]):
    pass

accrocchio.how_many()     # here we have 1, as you have declared a smelly parameter
detonator.how_many()     # here we have 1, as you have declared a smelly parameter

f(1)
accrocchio.how_many()     # here we still have 1
detonator.how_many()     # here we still have 1

The library also implements Michael Duell’s resign patterns.

from accrocchio.badgeofshame import accrocchio, detonator


@accrocchio
def accrocchio_fun():
    pass


@detonator
def detonator_fun():
    pass


accrocchio_fun()
accrocchio.how_many()     # here we have 1, as you have invoked an accrocchio function
detonator.how_many()      # here we have 0, as you have never invoked a detonator function
detonator_fun()
detonator.how_many()      # here we have 1, as you have invoked a detonator function
accrocchio.how_many()     # here we have 2, as you have invoked a detonator function, which is an accrocchio

You may mark arbitrary code as an accrocchio:

from accrocchio.badgeofshame import detonator, epoxy, this_is_a, this_is_an

this_is_an(epoxy)
this_is_a(detonator)
detonator.how_many()  # this will be 1
epoxy.how_many()  # this will be 1

If you need to have to mark a specific portion of your code as an accrocchio, you can use it as a context manager, as follows:

from accrocchio.badgeofshame import detonator, epoxy

with detonator:
    ...

with epoxy:
    ...

detonator.how_many()  # this will be 1
epoxy.how_many()  # this will be 1

For a full list of the implemented accrocchio resign patterns, please consult Michael Duell’s resign patterns.

Some final notes:

  1. This library is useful only if a small part of the software is an accrocchio

  2. We intentionally left out Python versions before 3.5, as we think they are a complete accrocchio.

  3. We intentionally did not pass the accrocchio to the ‘on_accrocchio’ observer function, as you should treat all the accrocchioes the same way

  4. The plural for accrocchio is accrocchioes

  5. If you are using this library, you are deliberately brutalizing The Zen of Python; thus it has been replaced with a more appropriate one. Just do import this after import accrocchio.

Metadata

Release files for accrocchio 0.1.14

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

Source distribution (sdist)

Source distribution for accrocchio 0.1.14
File Size Uploaded Provenance
accrocchio-0.1.14.tar.gz 7.0 kB Without provenance Details

Release files / accrocchio-0.1.14.tar.gz

Download URL accrocchio-0.1.14.tar.gz
Size 7.0 kB
Tags Source
SHA-256 checksum
How to use checksums
9c8dc50b8a9a5f4387ffaac1718391e8a6ab2fbb635d70b08d4843a43ae11bb1
BLAKE2b-256 checksum
How to use checksums
23498146fc33a0bef7770fa2ec7e3b713df50bd0e4d6b3d2b101b5a9c1f56f99
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.8.1 pkginfo/1.4.1 requests/2.19.1 setuptools/35.0.2 requests-toolbelt/0.7.1 clint/0.5.1 CPython/2.7.17 Linux/4.15.0-128-generic

Security for accrocchio 0.1.14

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