{"categories":[{"label":"Testing","url":"https://skillfed.io/packages/category/software-development-testing/3"}],"enrichment":{"capability":"Provides a decorator that enforces singleton pattern on classes while preserving direct access to the underlying class for unit testing via the `__wrapped__` attribute.","skillfed_tags":["singleton-pattern","testing-utilities"],"use_cases":["Enforce singleton pattern on configuration or service classes that should have exactly one instance across an application.","Unit test singleton-decorated classes by calling methods directly on `__wrapped__` with mock objects, avoiding constructor execution.","Ensure test isolation by accessing the underlying class without triggering singleton instance creation or initialization logic.","Replace hand-written singleton boilerplate with a simple decorator for cleaner, more readable class definitions."],"what_it_does":"singleton-decorator is a minimal Python decorator that enforces the singleton pattern\u2014ensuring only one instance of a decorated class exists\u2014while solving a key testing problem. Standard singleton decorators wrap a class in a function, making the class inaccessible for direct method calls in unit tests. This package instead uses a wrapper object that exposes the original class via `__wrapped__`, allowing tests to call class methods in isolation without instantiation.\n\nThe decorator is straightforward to use: apply `@singleton` to any class, then instantiate it normally. All calls return the same instance. For unit testing, access `ClassName.__wrapped__` to get the raw class and call its methods with mock objects as `self`, avoiding constructor side effects and test isolation problems.","worth_installing":"No. The package is under GPLv3 copyleft, which restricts use in proprietary or permissively-licensed projects. More critically, it has been dormant since 2017 with no Python version specification and no updates for modern Python ecosystems. The core functionality is trivial to implement inline (a few lines of code), and the lack of maintenance creates compatibility and security uncertainty. Use only if you are in a GPLv3-compatible codebase and willing to accept the maintenance risk."},"id":"singleton-decorator","links":{"html":"https://skillfed.io/packages/singleton-decorator","md":"https://skillfed.io/packages/singleton-decorator.md","pypi":"https://pypi.org/project/singleton-decorator/"},"maintenance":{"status":"dormant"},"meta":{"latest_release":"2017-08-10","license_spdx":null,"license_treatment":"copyleft","name":"singleton-decorator","python_support":"unspecified","summary":"A testable singleton decorator"},"popularity":{"monthly_downloads":541980,"position":6091,"tier":"top_15000"},"security":{"n_vulnerabilities":0},"version":"1.0.0"}
