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 Common errors
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.
Warnings
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.
Imports
- call_from wrong
from sorcery.core import call_fromcorrectfrom sorcery import call_from - delegate_to_instance
from sorcery import delegate_to_instance - spell
from sorcery import spell
Quickstart
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')