{"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,"search_vec":"'0.3.0':15 '3.10':18 '3.14':19 'cadenc':22 'class':29 'class-transform':28 'creat':5 'current':20 'decor':27 'function':13,25 'immut':26 'irregular':24 'librari':3 'mutat':9 'object':8 'object-mut':7 'pure':12 'purifi':1 'python':6,17 'releas':21 'support':16 'transform':10,30 'version':14","created_at":"2026-05-01T08:12:13.331084+00:00","updated_at":"2026-05-01T08:12:13.331084+00:00","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,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.3.0","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/xoeye/purify","docs":null,"changelog":null,"pypi":"https://pypi.org/project/purify/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-29","last_verified":"2026-06-29","next_check":"2026-07-29","install_tag":null}}