{"id":24276,"library":"purify","title":"Purify","description":"A library for creating Pythonic object-mutator transforms as pure functions. Version 0.3.0 supports Python 3.10–3.14. Current release cadence is irregular.","status":"active","version":"0.3.0","language":"python","source_language":"en","source_url":"https://github.com/xoeye/purify","tags":["functional","immutability","decorator","class-transformer"],"install":[{"cmd":"pip install purify","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"The main decorator/function is named 'purify'.","symbol":"purify","correct":"from purify import purify"}],"quickstart":{"code":"from purify import purify\n\n@purify\nclass Person:\n    def __init__(self, name, age):\n        self.name = name\n        self.age = age\n\np = Person('Alice', 30)\n# Now p.name = 'Alice', p.age = 30\n# Under the hood, mutating methods return new instances\n","lang":"python","description":"Decorate a class with @purify to make all instance methods return new objects instead of mutating the original."},"warnings":[{"fix":"Upgrade to Python >=3.10 or pin purify<0.3.0.","message":"Purify 0.3.0 drops support for Python < 3.10. If you are on Python 3.9 or older, pin to <0.3.0.","severity":"breaking","affected_versions":"<0.3.0"},{"fix":"Ensure your class __init__ only sets attributes directly (e.g., self.x = x). Avoid property setters or custom __setattr__.","message":"The @purify decorator only works on classes with a well-defined __init__ that uses simple attribute assignment. Classes with complex initialization or metaclasses may not be supported.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Reassign the result: p = p.update_name('Bob') instead of p.update_name('Bob').","cause":"Calling a mutating method on an instance and expecting the original to change. Because purify returns a new object, the original is unchanged.","error":"AttributeError: 'NoneType' object has no attribute 'name'"},{"fix":"Remove any return statements from __init__ and avoid overriding __new__.","cause":"Attempting to use @purify on a class that already returns a new instance from __init__ or uses a custom __new__. Purify expects __init__ to set attributes only.","error":"TypeError: __init__() should return None, not 'Person'"},{"fix":"Use 'from purify import purify' and ensure you have purify >=0.2.0.","cause":"Older versions of purify (pre-0.2.0) had a different module structure. The correct import is 'from purify import purify' (the decorator and the package share the same name).","error":"ImportError: cannot import name 'purify' from 'purify'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}