{"id":24782,"library":"undecorated","title":"undecorated","description":"A library to undecorate Python functions, methods, or classes, returning the original callable before any decorators were applied. Version 0.3.0 is the latest; the project is in maintenance mode with no recent releases.","status":"maintenance","version":"0.3.0","language":"python","source_language":"en","source_url":"https://github.com/mapleoin/undecorated","tags":["decorator","undecorate","reflection","utility"],"install":[{"cmd":"pip install undecorated","lang":"bash","label":"pip install"}],"dependencies":[],"imports":[{"note":"undecorate is a function, not a module","wrong":"import undecorate","symbol":"undecorate","correct":"from undecorated import undecorate"}],"quickstart":{"code":"from undecorated import undecorate\n\ndef decorator(func):\n    def wrapper(*args, **kwargs):\n        return func(*args, **kwargs)\n    return wrapper\n\n@decorator\ndef foo():\n    return 'foo'\n\nprint(foo())            # calls wrapper\nprint(undecorate(foo))  # returns original function\nprint(undecorate(foo)()) # 'foo'","lang":"python","description":"Basic usage: undecorate a decorated function to get the original."},"warnings":[{"fix":"Check the result; if the original function isn't found, consider alternative approaches like storing the original manually.","message":"undecorate() works by inspecting closure cells, which may fail for complex decorators (e.g., functools.lru_cache, class-based decorators, or decorators that return a different type).","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Verify the function is actually decorated before undecorating to avoid logic errors.","message":"Applying undecorate to an already undecorated function returns the same function; it does not error. This can mask misuses.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Test on your Python version; if it fails, consider forking or using an alternative library.","message":"Does not support Python 3.12+ if decorators use new closure behavior or PEP 695 (type parameter syntax) changes. The package has not been updated for recent CPython internals.","severity":"gotcha","affected_versions":">=0.3.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Ensure the argument is a decorated Python function with a closure; check if the function is decorated.","cause":"Attempting to undecorate a built-in function or a function without a closure (e.g., lambda or a function defined in C).","error":"AttributeError: 'function' object has no attribute '__closure__'"},{"fix":"Only use undecorate on callables that are known to be decorated functions.","cause":"undecorate may return a non-callable if the original object is not a function (e.g., a descriptor or property).","error":"TypeError: 'int' object is not callable"},{"fix":"Use correct import: 'from undecorated import undecorate'","cause":"Importing incorrectly (e.g., 'import undecorate' instead of 'from undecorated import undecorate').","error":"NameError: name 'undecorate' is not defined"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}