{"id":6779,"library":"property-manager","title":"Property Manager","description":"The `property-manager` package, currently at version 3.0, provides useful property variants for Python programming, extending Python's built-in `property` descriptor. It offers decorators for creating required properties, writable properties, and cached properties, as well as a `PropertyManager` base class with enhanced constructor behavior and `repr()` customization. The library has a stable release cadence, with version 3.0 released in 2020, and is designed to make managing class attributes more robust and flexible.","status":"active","version":"3.0","language":"python","source_language":"en","source_url":"https://github.com/xolox/python-property-manager","tags":["python","properties","descriptors","caching","required-properties","writable-properties","object-oriented"],"install":[{"cmd":"pip install property-manager","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"symbol":"PropertyManager","correct":"from property_manager import PropertyManager"},{"symbol":"writable_property","correct":"from property_manager import writable_property"},{"symbol":"required_property","correct":"from property_manager import required_property"},{"symbol":"cached_property","correct":"from property_manager import cached_property"}],"quickstart":{"code":"from property_manager import PropertyManager, required_property, writable_property, cached_property\nimport random\n\nclass MyManagedObject(PropertyManager):\n    @required_property\n    def name(self):\n        \"\"\"A name that must be provided during initialization.\"\"\"\n        pass\n\n    @writable_property\n    def value(self):\n        \"\"\"A writable property with a computed default.\"\"\"\n        return random.randint(1, 100)\n\n    @cached_property\n    def expensive_calculation(self):\n        \"\"\"A property whose value is computed once and cached.\"\"\"\n        print(\"Calculating expensive_calculation...\")\n        return sum(range(self.value * 1000))\n\n# Instantiate with a required property\nobj = MyManagedObject(name=\"Example Item\")\n\n# Access writable property (gets default initially)\nprint(f\"Initial value: {obj.value}\")\n\n# Set writable property\nobj.value = 200\nprint(f\"New value: {obj.value}\")\n\n# Access cached property (computes once)\nprint(f\"Expensive calculation (first access): {obj.expensive_calculation}\")\nprint(f\"Expensive calculation (second access): {obj.expensive_calculation}\")\n\n# Attempt to create an object without a required property\ntry:\n    MyManagedObject()\nexcept TypeError as e:\n    print(f\"Caught expected error: {e}\")","lang":"python","description":"This example demonstrates defining a class using `PropertyManager` with `required_property`, `writable_property`, and `cached_property`. It shows how required properties are enforced at instantiation, how writable properties can have computed defaults and be assigned new values, and how cached properties compute their value only once upon first access."},"warnings":[{"fix":"Always provide values for `required_property` via keyword arguments in the `PropertyManager` subclass constructor.","message":"Classes inheriting from `PropertyManager` will raise a `TypeError` during instantiation if a `required_property` is not provided as a keyword argument to the constructor.","severity":"gotcha","affected_versions":"3.0 and earlier"},{"fix":"For thread-safe or time-sensitive caching, use a different library or implement custom locking/invalidation. For manual invalidation, use the `clear_cached_properties()` method on `PropertyManager` subclasses.","message":"The `cached_property` in `property-manager` does not support threading or time-based cache invalidation, unlike some other cached property implementations (e.g., `cached-property` library). If you need these features, consider alternatives or implement custom cache invalidation logic.","severity":"gotcha","affected_versions":"3.0 and earlier"},{"fix":"Be aware that constructor keyword arguments can override the initial computed default of `writable_property`. If you need to prevent this, implement custom constructor logic.","message":"Values for `writable_property` instances on `PropertyManager` subclasses can be set directly via keyword arguments during object instantiation. This can lead to unexpected behavior if not accounted for when designing constructors or expecting properties to always start with their computed defaults.","severity":"gotcha","affected_versions":"3.0 and earlier"}],"env_vars":null,"search_vec":"'2020':65 '3.0':11,62 'attribut':73 'base':44 'behavior':49 'built':23 'built-in':22 'cach':37,81 'cadenc':59 'class':45,72 'constructor':48 'creat':31 'current':8 'custom':52 'decor':29 'descriptor':26,80 'design':68 'enhanc':47 'extend':19 'flexibl':77 'librari':54 'make':70 'manag':2,6,71 'object':89 'object-ori':88 'offer':28 'orient':90 'packag':7 'program':18 'properti':1,5,14,25,33,35,38,79,84,87 'property-manag':4 'propertymanag':43 'provid':12 'python':17,20,78 'releas':58,63 'repr':51 'requir':32,83 'required-properti':82 'robust':75 'stabl':57 'use':13 'variant':15 'version':10,61 'well':40 'writabl':34,86 'writable-properti':85","created_at":"2026-04-15T18:42:37.119277+00:00","updated_at":"2026-04-16T18:12:07.354745+00:00","problems":[{"fix":"Provide a value for the required property as a keyword argument during object instantiation. For example: `my_instance = MyClass(attribute_name='some_value')`","cause":"You tried to instantiate a `PropertyManager` subclass but did not provide a value for a property decorated with `@required_property`.","error":"TypeError: Required property 'attribute_name' not set"},{"fix":"Ensure that all keyword arguments passed to the `PropertyManager` constructor match the names of existing properties defined in the class.","cause":"You passed a keyword argument to the constructor of a `PropertyManager` subclass that does not correspond to any defined property on the class.","error":"TypeError: keyword argument 'unknown_arg' doesn't match a property"},{"fix":"If the property is intended to be writable, define it using `@writable_property` or `@cached_property(writable=True)`. If it's a `required_property`, its value can only be set during initialization and cannot be changed later.","cause":"You attempted to assign a value to a property that was not defined as `writable` (i.e., `writable=False` or it's a `required_property` which is implicitly non-writable after initial setting, or a `cached_property` without `writable=True`).","error":"AttributeError: property 'my_property' cannot be set"},{"fix":"Install the package using pip: `pip install property-manager` (note the hyphen). Ensure your import statement uses an underscore: `from property_manager import PropertyManager`.","cause":"The `property-manager` library is either not installed in your Python environment or there's a typo in the import statement.","error":"ModuleNotFoundError: No module named 'property_manager'"},{"fix":"If the property is intended to be deletable (to reset its value to its computed default), define it with `resettable=True` in its decorator, e.g., `@cached_property(resettable=True)`.","cause":"You attempted to delete a property that was not defined as `resettable` (i.e., `resettable=False`).","error":"AttributeError: property 'my_property' cannot be deleted"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"3.0","cli_name":"","cli_version":null,"type":"library","homepage":"https://property-manager.readthedocs.io","github":null,"docs":null,"changelog":null,"pypi":"https://pypi.org/project/property-manager/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":[],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-28","install_tag":null}}