sorcery

raw JSON →
0.2.2 verified Sat May 09 auth: no python abandoned

A library of dark magic delights for Python, providing a set of utility decorators and context managers for cleaner code. Currently at version 0.2.2 (though effectively abandoned since 2020). No release cadence; last release May 2019.

pip install sorcery
error ModuleNotFoundError: No module named 'sorcery'
cause Not installed.
fix
pip install sorcery
error AttributeError: module 'sorcery' has no attribute 'call_from'
cause Importing from wrong location or version conflict.
fix
Use: from sorcery import call_from
error TypeError: call_from() missing 1 required positional argument: 'calling_frame'
cause The function signature changed in older versions.
fix
Use version 0.2.2 and ensure correct usage: call_from() without arguments.
abandoned Repository archived and no updates since 2020. Not compatible with Python 3.11+ due to reliance on removed inspect features.
fix Consider alternatives like 'magicattr' or implement own utilities.
breaking The library modifies frame introspection and may break in newer Python versions (especially 3.11+).
fix Avoid using in production; test thoroughly.
deprecated No official deprecation, but effectively unmaintained.
fix Pin version if you must use, but prefer migration.

Basic usage of call_from and spell decorator.

from sorcery import call_from, spell, delegate_to_instance

class Foo:
    def __init__(self):
        self.x = 10

    @spell
    def bar(self):
        return call_from()  # returns (self, 'bar')

foo = Foo()
assert foo.bar() == (foo, 'bar')

print('Quickstart works')