{"id":26246264,"url":"https://github.com/emcd/python-accretive","last_synced_at":"2025-04-23T20:27:12.927Z","repository":{"id":245506155,"uuid":"818422687","full_name":"emcd/python-accretive","owner":"emcd","description":null,"archived":false,"fork":false,"pushed_at":"2025-04-11T02:07:08.000Z","size":465,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-11T03:21:04.743Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/emcd.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-06-21T20:24:39.000Z","updated_at":"2025-04-11T02:07:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"b776068d-4c17-4129-ab24-e4b3e62d0c6f","html_url":"https://github.com/emcd/python-accretive","commit_stats":null,"previous_names":["emcd/python-accretive"],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emcd%2Fpython-accretive","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emcd%2Fpython-accretive/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emcd%2Fpython-accretive/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emcd%2Fpython-accretive/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/emcd","download_url":"https://codeload.github.com/emcd/python-accretive/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250508176,"owners_count":21442170,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-13T13:17:44.364Z","updated_at":"2025-04-23T20:27:12.902Z","avatar_url":"https://github.com/emcd.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":".. vim: set fileencoding=utf-8:\n.. -*- coding: utf-8 -*-\n.. +--------------------------------------------------------------------------+\n   |                                                                          |\n   | Licensed under the Apache License, Version 2.0 (the \"License\");          |\n   | you may not use this file except in compliance with the License.         |\n   | You may obtain a copy of the License at                                  |\n   |                                                                          |\n   |     http://www.apache.org/licenses/LICENSE-2.0                           |\n   |                                                                          |\n   | Unless required by applicable law or agreed to in writing, software      |\n   | distributed under the License is distributed on an \"AS IS\" BASIS,        |\n   | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |\n   | See the License for the specific language governing permissions and      |\n   | limitations under the License.                                           |\n   |                                                                          |\n   +--------------------------------------------------------------------------+\n\n\n*******************************************************************************\n                                   accretive                                   \n*******************************************************************************\n\n.. image:: https://img.shields.io/pypi/v/accretive\n   :alt: Package Version\n   :target: https://pypi.org/project/accretive/\n\n.. image:: https://img.shields.io/pypi/status/accretive\n   :alt: PyPI - Status\n   :target: https://pypi.org/project/accretive/\n\n.. image:: https://github.com/emcd/python-accretive/actions/workflows/tester.yaml/badge.svg?branch=master\u0026event=push\n   :alt: Tests Status\n   :target: https://github.com/emcd/python-accretive/actions/workflows/tester.yaml\n\n.. image:: https://emcd.github.io/python-accretive/coverage.svg\n   :alt: Code Coverage Percentage\n   :target: https://github.com/emcd/python-accretive/actions/workflows/tester.yaml\n\n.. image:: https://img.shields.io/github/license/emcd/python-accretive\n   :alt: Project License\n   :target: https://github.com/emcd/python-accretive/blob/master/LICENSE.txt\n\n.. image:: https://img.shields.io/pypi/pyversions/accretive\n   :alt: Python Versions\n   :target: https://pypi.org/project/accretive/\n\n\n🌌 A Python library package which provides **accretive data structures** -\ncollections which can grow but never shrink.\n\n\nKey Features ⭐\n===============================================================================\n\n* 📖 **Accretive Dictionary**: Like a regular `dict\n  \u003chttps://docs.python.org/3/library/stdtypes.html#dict\u003e`_, but entries cannot\n  be modified or removed once added. Also has variants with defaults and\n  validation.\n* 🗃️ **Accretive Namespace**: Similar to `SimpleNamespace\n  \u003chttps://docs.python.org/3/library/types.html#types.SimpleNamespace\u003e`_, but\n  attributes become immutable after assignment.\n* 🧱 **Additional Types**: Classes (including abstract base classes), modules,\n  and objects with accretive behavior.\n* 🏗️ **Flexible Initialization**: Support for unprotected attributes during\n  initialization; useful for compatibility with class decorators, such as\n  `dataclasses\n  \u003chttps://docs.python.org/3/library/dataclasses.html#dataclasses.dataclass\u003e`_.\n* 🔓 **Flexible Mutability**: Support for declaring specific attributes as\n  mutable, enabling selective modification while maintaining immutability for\n  other attributes.\n\n\nInstallation 📦\n===============================================================================\n\n::\n\n    pip install accretive\n\n\nNote on Immutability 📢\n===============================================================================\n\n   Enforcement of immutability is quite difficult in Python. While this library\n   encourages immutability by default, it can be circumvented by anyone who has\n   intermediate knowledge of Python machinery and who is determined to\n   circumvent the immutability. Use the library in the spirit of making\n   programs safer, but understand that it cannot truly prevent unwanted state\n   tampering.\n\n\nExamples 💡\n===============================================================================\n\n\nAccretive Namespaces 🗃️\n-------------------------------------------------------------------------------\n\nAn accretive namespace, similar to ``types.SimpleNamespace``, is available.\nThis namespace can be initialized from multiple iterables and from keyword\narguments. (Keyword arguments shown below; see documentation for additional\nforms of initialization.)\n\n\u003e\u003e\u003e from accretive import Namespace\n\u003e\u003e\u003e ns = Namespace( apples = 12, bananas = 6 )\n\u003e\u003e\u003e ns.cherries = 42  # ✅ Allows new attributes.\n\u003e\u003e\u003e ns.apples = 14    # ❌ Attempted reassignment raises error.\nTraceback (most recent call last):\n...\naccretive.exceptions.AttributeImmutabilityError: Cannot reassign or delete existing attribute 'apples'.\n\u003e\u003e\u003e del ns.apples     # ❌ Attempted deletion raises error.\nTraceback (most recent call last):\n...\naccretive.exceptions.AttributeImmutabilityError: Cannot reassign or delete existing attribute 'apples'.\n\u003e\u003e\u003e ns\naccretive.namespaces.Namespace( apples = 12, bananas = 6, cherries = 42 )\n\n\nAccretive Dictionaries 📖\n-------------------------------------------------------------------------------\n\nAn accretive dictionary, similar to ``dict``, is available. This dictionary can\nbe initialized from multiple iterables and from keyword arguments. (Keyword\narguments shown below; see documentation for additional forms of\ninitialization.)\n\n\u003e\u003e\u003e from accretive import Dictionary\n\u003e\u003e\u003e dct = Dictionary( apples = 12, bananas = 6 )\n\u003e\u003e\u003e dct[ 'cherries' ] = 42  # ✅ Allows new entries.\n\u003e\u003e\u003e dct.update( blueberries = 96, strawberries = 24 )\naccretive.dictionaries.Dictionary( {'apples': 12, 'bananas': 6, 'cherries': 42, 'blueberries': 96, 'strawberries': 24} )\n\u003e\u003e\u003e dct[ 'bananas' ] = 11   # ❌ Attempted alteration raises error.\nTraceback (most recent call last):\n...\naccretive.exceptions.EntryImmutabilityError: Cannot alter or remove existing entry for 'bananas'.\n\u003e\u003e\u003e del dct[ 'bananas' ]    # ❌ Attempted removal raises error.\nTraceback (most recent call last):\n...\naccretive.exceptions.EntryImmutabilityError: Cannot alter or remove existing entry for 'bananas'.\n\u003e\u003e\u003e dct\naccretive.dictionaries.Dictionary( {'apples': 12, 'bananas': 6, 'cherries': 42, 'blueberries': 96, 'strawberries': 24} )\n\n\nAccretive Objects 🧱\n-------------------------------------------------------------------------------\n\nThe ``accretive`` decorator can be applied to any class to make its instances enforce attribute immutability after assignment.\n\n\u003e\u003e\u003e from accretive import accretive\n\u003e\u003e\u003e @accretive\n... class Config:\n...     def __init__( self, debug = False ):\n...         self.debug = debug\n...\n\u003e\u003e\u003e config = Config( debug = True )\n\u003e\u003e\u003e config.verbose = True  # ✅ Allows new attributes\n\u003e\u003e\u003e config.debug = False   # ❌ Attempted reassignment raises error\nTraceback (most recent call last):\n...\naccretive.exceptions.AttributeImmutabilityError: Cannot reassign or delete existing attribute 'debug'.\n\n\nUse Cases 🎯\n===============================================================================\n\n* 📝 **Configuration Registries**: Registries which can accumulate entries but\n  never remove them, thereby guaranteeing sticky state.\n* 🔌 **Plugin Systems**: Register extensions which are then guaranteed to be\n  available from the time of registration to the end of the process.\n* 🔒 **Immutable Collections**: Many scenarios requiring grow-only collections\n  with immutability guarantees.\n\n\n`More Flair \u003chttps://www.imdb.com/title/tt0151804/characters/nm0431918\u003e`_\n===============================================================================\n\n.. image:: https://img.shields.io/github/last-commit/emcd/python-accretive\n   :alt: GitHub last commit\n   :target: https://github.com/emcd/python-accretive\n\n.. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/copier-org/copier/master/img/badge/badge-grayscale-inverted-border-orange.json\n   :alt: Copier\n   :target: https://github.com/copier-org/copier\n\n.. image:: https://img.shields.io/badge/%F0%9F%A5%9A-Hatch-4051b5.svg\n   :alt: Hatch\n   :target: https://github.com/pypa/hatch\n\n.. image:: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit\n   :alt: pre-commit\n   :target: https://github.com/pre-commit/pre-commit\n\n.. image:: https://microsoft.github.io/pyright/img/pyright_badge.svg\n   :alt: Pyright\n   :target: https://microsoft.github.io/pyright\n\n.. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json\n   :alt: Ruff\n   :target: https://github.com/astral-sh/ruff\n\n.. image:: https://img.shields.io/pypi/implementation/accretive\n   :alt: PyPI - Implementation\n   :target: https://pypi.org/project/accretive/\n\n.. image:: https://img.shields.io/pypi/wheel/accretive\n   :alt: PyPI - Wheel\n   :target: https://pypi.org/project/accretive/\n\n\nOther Projects by This Author 🌟\n===============================================================================\n\n\n* `python-absence \u003chttps://github.com/emcd/python-absence\u003e`_\n    - PyPI: `absence \u003chttps://pypi.org/project/absence/\u003e`_\n\n    🕳️ A Python library package which provides a **sentinel for absent values** - a falsey, immutable singleton that represents the absence of a value in contexts where ``None`` or ``False`` may be valid values.\n* `python-falsifier \u003chttps://github.com/emcd/python-falsifier\u003e`_\n    - PyPI: `falsifier \u003chttps://pypi.org/project/falsifier/\u003e`_\n\n    🎭 A very simple Python library package which provides a **base class for falsey objects** - objects that evaluate to ``False`` in boolean contexts.\n* `python-frigid \u003chttps://github.com/emcd/python-frigid\u003e`_\n    - PyPI: `frigid \u003chttps://pypi.org/project/frigid/\u003e`_\n\n    🔒 A Python library package which provides **immutable data structures** - collections which cannot be modified after creation.\n* `python-icecream-truck \u003chttps://github.com/emcd/python-icecream-truck\u003e`_\n    - PyPI: `icecream-truck \u003chttps://pypi.org/project/icecream-truck/\u003e`_\n\n    🍦 **Flavorful Debugging** - A Python library which enhances the powerful and well-known ``icecream`` package with flavored traces, configuration hierarchies, customized outputs, ready-made recipes, and more.\n* `python-mimeogram \u003chttps://github.com/emcd/python-mimeogram\u003e`_\n    - PyPI: `mimeogram \u003chttps://pypi.org/project/mimeogram/\u003e`_\n\n    📨 A command-line tool for **exchanging collections of files with Large Language Models** - bundle multiple files into a single clipboard-ready document while preserving directory structure and metadata... good for code reviews, project sharing, and LLM interactions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femcd%2Fpython-accretive","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femcd%2Fpython-accretive","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femcd%2Fpython-accretive/lists"}