.. vim: set fileencoding=utf-8:
.. -*- coding: utf-8 -*-
.. +--------------------------------------------------------------------------+
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| |
+--------------------------------------------------------------------------+
*******************************************************************************
frigid
*******************************************************************************
.. image:: https://img.shields.io/pypi/v/frigid
:alt: Project Version
:target: https://pypi.org/project/frigid/
.. image:: https://img.shields.io/pypi/status/frigid
:alt: PyPI - Status
:target: https://pypi.org/project/frigid/
.. image:: https://github.com/emcd/python-frigid/actions/workflows/tester.yaml/badge.svg?branch=master&event=push
:alt: Tests Status
:target: https://github.com/emcd/python-frigid/actions/workflows/tester.yaml
.. image:: https://emcd.github.io/python-frigid/coverage.svg
:alt: Code Coverage Percentage
:target: https://github.com/emcd/python-frigid/actions/workflows/tester.yaml
.. image:: https://img.shields.io/pypi/pyversions/frigid
:alt: Python Versions
:target: https://pypi.org/project/frigid/
.. image:: https://img.shields.io/pypi/l/frigid
:alt: Project License
:target: https://github.com/emcd/python-frigid/blob/master/LICENSE.txt
🔒 A Python library package which provides **immutable data structures** -
collections which cannot be modified after creation.
Key Features ⭐
===============================================================================
* 📖 **Immutable Dictionary**: Like a regular `dict
<https://docs.python.org/3/library/stdtypes.html#dict>`_, but entries cannot
be modified or removed. Also has variant for validation on initialization.
And provides set operations not found on `MappingProxyType
<https://docs.python.org/3/library/types.html#types.MappingProxyType>`_.
* 📇 **Immutable Namespace**: Similar to `SimpleNamespace
<https://docs.python.org/3/library/types.html#types.SimpleNamespace>`_, but
attributes are immutable from creation.
* 🧱 **Additional Types**: Classes (including abstract base classes), modules,
and objects with immutable behavior.
* 🏗️ **Flexible Initialization**: Support for unprotected attributes during
initialization; useful for compatibility with class decorators, such as
`dataclasses
<https://docs.python.org/3/library/dataclasses.html#dataclasses.dataclass>`_.
Note on Immutability 📢
===============================================================================
Enforcement of immutability is quite difficult in Python. While this library
enforces immutability by default, it can be circumvented by anyone who has
intermediate knowledge of Python machinery and who is determined to
circumvent the immutability. Use the library in the spirit of making
programs safer, but understand that it cannot truly prevent unwanted state
tampering.
Installation 📦
===============================================================================
::
pip install frigid
Examples 💡
===============================================================================
Immutable Namespace 📇
-------------------------------------------------------------------------------
An immutable namespace, similar to ``types.SimpleNamespace``, is available.
This namespace is initialized from keyword arguments and becomes completely
immutable. (Keyword arguments shown below; see documentation for additional
forms of initialization.)
>>> from frigid import Namespace
>>> ns = Namespace( apples = 12, bananas = 6 )
>>> ns.cherries = 42 # ❌ Attempted assignment raises error.
Traceback (most recent call last):
...
frigid.exceptions.AttributeImmutabilityError: Cannot assign attribute 'cherries'.
>>> del ns.apples # ❌ Attempted deletion raises error.
Traceback (most recent call last):
...
frigid.exceptions.AttributeImmutabilityError: Cannot delete attribute 'apples'.
>>> ns
frigid.namespaces.Namespace( apples = 12, bananas = 6 )
Immutable Dictionary 📖
-------------------------------------------------------------------------------
An immutable dictionary, similar to ``dict``, is available. This dictionary is
initialized from iterables and keyword arguments and becomes completely
immutable. (Keyword arguments shown below; see documentation for additional
forms of initialization.)
>>> from frigid import Dictionary
>>> dct = Dictionary( apples = 12, bananas = 6)
>>> dct['cherries'] = 42 # ❌ Attempted assignment raises error.
Traceback (most recent call last):
...
frigid.exceptions.EntryImmutabilityError: Cannot assign entry for 'cherries'.
>>> del dct['bananas'] # ❌ Attempted removal raises error.
Traceback (most recent call last):
...
frigid.exceptions.EntryImmutabilityError: Cannot delete entry for 'bananas'.
>>> dct
frigid.dictionaries.Dictionary( {'apples': 12, 'bananas': 6} )
Use Cases 🎯
===============================================================================
* 🔒 **Configuration Objects**: Objects which must maintain consistent state
throughout program execution.
* 📊 **Value Objects**: Objects which represent values and should be immutable,
like numbers or strings.
* 🧱 **Immutable Collections**: Many scenarios requiring collections with
complete immutability guarantees.
`More Flair <https://www.imdb.com/title/tt0151804/characters/nm0431918>`_
===============================================================================
.. image:: https://img.shields.io/github/last-commit/emcd/python-frigid
:alt: GitHub last commit
:target: https://github.com/emcd/python-frigid
.. image:: https://img.shields.io/badge/%F0%9F%A5%9A-Hatch-4051b5.svg
:alt: Hatch
:target: https://github.com/pypa/hatch
.. image:: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit
:alt: pre-commit
:target: https://github.com/pre-commit/pre-commit
.. image:: https://img.shields.io/badge/security-bandit-yellow.svg
:alt: Bandit
:target: https://github.com/PyCQA/bandit
.. image:: https://img.shields.io/badge/linting-pylint-yellowgreen
:alt: Pylint
:target: https://github.com/pylint-dev/pylint
.. image:: https://microsoft.github.io/pyright/img/pyright_badge.svg
:alt: Pyright
:target: https://microsoft.github.io/pyright/
.. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
:alt: Ruff
:target: https://github.com/astral-sh/ruff
.. image:: https://img.shields.io/badge/hypothesis-tested-brightgreen.svg
:alt: Hypothesis
:target: https://hypothesis.readthedocs.io/en/latest/
.. image:: https://img.shields.io/pypi/implementation/frigid
:alt: PyPI - Implementation
:target: https://pypi.org/project/frigid/
.. image:: https://img.shields.io/pypi/wheel/frigid
:alt: PyPI - Wheel
:target: https://pypi.org/project/frigid/
Raw data
{
"_id": null,
"home_page": null,
"name": "frigid",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "api, dictionary, immutability, immutable, namespace",
"author": null,
"author_email": "Eric McDonald <emcd@users.noreply.github.com>",
"download_url": "https://files.pythonhosted.org/packages/85/13/fee99c8812583fe531630018d462157d4c7473284e1a5636aab492ae6eb5/frigid-1.0.tar.gz",
"platform": null,
"description": ".. 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 frigid\n*******************************************************************************\n\n.. image:: https://img.shields.io/pypi/v/frigid\n :alt: Project Version\n :target: https://pypi.org/project/frigid/\n\n.. image:: https://img.shields.io/pypi/status/frigid\n :alt: PyPI - Status\n :target: https://pypi.org/project/frigid/\n\n.. image:: https://github.com/emcd/python-frigid/actions/workflows/tester.yaml/badge.svg?branch=master&event=push\n :alt: Tests Status\n :target: https://github.com/emcd/python-frigid/actions/workflows/tester.yaml\n\n.. image:: https://emcd.github.io/python-frigid/coverage.svg\n :alt: Code Coverage Percentage\n :target: https://github.com/emcd/python-frigid/actions/workflows/tester.yaml\n\n.. image:: https://img.shields.io/pypi/pyversions/frigid\n :alt: Python Versions\n :target: https://pypi.org/project/frigid/\n\n.. image:: https://img.shields.io/pypi/l/frigid\n :alt: Project License\n :target: https://github.com/emcd/python-frigid/blob/master/LICENSE.txt\n\n\n\ud83d\udd12 A Python library package which provides **immutable data structures** -\ncollections which cannot be modified after creation.\n\n\nKey Features \u2b50\n===============================================================================\n\n* \ud83d\udcd6 **Immutable Dictionary**: Like a regular `dict\n <https://docs.python.org/3/library/stdtypes.html#dict>`_, but entries cannot\n be modified or removed. Also has variant for validation on initialization.\n And provides set operations not found on `MappingProxyType\n <https://docs.python.org/3/library/types.html#types.MappingProxyType>`_.\n* \ud83d\udcc7 **Immutable Namespace**: Similar to `SimpleNamespace\n <https://docs.python.org/3/library/types.html#types.SimpleNamespace>`_, but\n attributes are immutable from creation.\n* \ud83e\uddf1 **Additional Types**: Classes (including abstract base classes), modules,\n and objects with immutable behavior.\n* \ud83c\udfd7\ufe0f **Flexible Initialization**: Support for unprotected attributes during\n initialization; useful for compatibility with class decorators, such as\n `dataclasses\n <https://docs.python.org/3/library/dataclasses.html#dataclasses.dataclass>`_.\n\n\nNote on Immutability \ud83d\udce2\n===============================================================================\n\n Enforcement of immutability is quite difficult in Python. While this library\n enforces 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\nInstallation \ud83d\udce6\n===============================================================================\n\n::\n\n pip install frigid\n\n\nExamples \ud83d\udca1\n===============================================================================\n\n\nImmutable Namespace \ud83d\udcc7\n-------------------------------------------------------------------------------\n\nAn immutable namespace, similar to ``types.SimpleNamespace``, is available.\nThis namespace is initialized from keyword arguments and becomes completely\nimmutable. (Keyword arguments shown below; see documentation for additional\nforms of initialization.)\n\n>>> from frigid import Namespace\n>>> ns = Namespace( apples = 12, bananas = 6 )\n>>> ns.cherries = 42 # \u274c Attempted assignment raises error.\nTraceback (most recent call last):\n...\nfrigid.exceptions.AttributeImmutabilityError: Cannot assign attribute 'cherries'.\n>>> del ns.apples # \u274c Attempted deletion raises error.\nTraceback (most recent call last):\n...\nfrigid.exceptions.AttributeImmutabilityError: Cannot delete attribute 'apples'.\n>>> ns\nfrigid.namespaces.Namespace( apples = 12, bananas = 6 )\n\n\nImmutable Dictionary \ud83d\udcd6\n-------------------------------------------------------------------------------\n\nAn immutable dictionary, similar to ``dict``, is available. This dictionary is\ninitialized from iterables and keyword arguments and becomes completely\nimmutable. (Keyword arguments shown below; see documentation for additional\nforms of initialization.)\n\n>>> from frigid import Dictionary\n>>> dct = Dictionary( apples = 12, bananas = 6)\n>>> dct['cherries'] = 42 # \u274c Attempted assignment raises error.\nTraceback (most recent call last):\n...\nfrigid.exceptions.EntryImmutabilityError: Cannot assign entry for 'cherries'.\n>>> del dct['bananas'] # \u274c Attempted removal raises error.\nTraceback (most recent call last):\n...\nfrigid.exceptions.EntryImmutabilityError: Cannot delete entry for 'bananas'.\n>>> dct\nfrigid.dictionaries.Dictionary( {'apples': 12, 'bananas': 6} )\n\n\nUse Cases \ud83c\udfaf\n===============================================================================\n\n* \ud83d\udd12 **Configuration Objects**: Objects which must maintain consistent state\n throughout program execution.\n* \ud83d\udcca **Value Objects**: Objects which represent values and should be immutable,\n like numbers or strings.\n* \ud83e\uddf1 **Immutable Collections**: Many scenarios requiring collections with\n complete immutability guarantees.\n\n\n`More Flair <https://www.imdb.com/title/tt0151804/characters/nm0431918>`_\n===============================================================================\n\n.. image:: https://img.shields.io/github/last-commit/emcd/python-frigid\n :alt: GitHub last commit\n :target: https://github.com/emcd/python-frigid\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://img.shields.io/badge/security-bandit-yellow.svg\n :alt: Bandit\n :target: https://github.com/PyCQA/bandit\n\n.. image:: https://img.shields.io/badge/linting-pylint-yellowgreen\n :alt: Pylint\n :target: https://github.com/pylint-dev/pylint\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/badge/hypothesis-tested-brightgreen.svg\n :alt: Hypothesis\n :target: https://hypothesis.readthedocs.io/en/latest/\n\n.. image:: https://img.shields.io/pypi/implementation/frigid\n :alt: PyPI - Implementation\n :target: https://pypi.org/project/frigid/\n\n.. image:: https://img.shields.io/pypi/wheel/frigid\n :alt: PyPI - Wheel\n :target: https://pypi.org/project/frigid/",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "Immutable data structures.",
"version": "1.0",
"project_urls": {
"Documentation": "https://emcd.github.io/python-frigid",
"Download": "https://pypi.org/project/frigid/#files",
"Homepage": "https://github.com/emcd/python-frigid",
"Issue Tracker": "https://github.com/emcd/python-frigid/issues",
"Source Code": "https://github.com/emcd/python-frigid"
},
"split_keywords": [
"api",
" dictionary",
" immutability",
" immutable",
" namespace"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "ef7ca553d01d65913a9083c08736324e5acd32e45f06930bc1efeede782aef47",
"md5": "2c1ff2637931b583587dbb1d20300f41",
"sha256": "a712fc7b6415278a3c462769ac5ac85ff07bab7b9d139dacd18bd0dc80ff9010"
},
"downloads": -1,
"filename": "frigid-1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2c1ff2637931b583587dbb1d20300f41",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 27754,
"upload_time": "2024-12-05T03:49:30",
"upload_time_iso_8601": "2024-12-05T03:49:30.940085Z",
"url": "https://files.pythonhosted.org/packages/ef/7c/a553d01d65913a9083c08736324e5acd32e45f06930bc1efeede782aef47/frigid-1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8513fee99c8812583fe531630018d462157d4c7473284e1a5636aab492ae6eb5",
"md5": "08cf356c91c7036a68836632a1b51eeb",
"sha256": "0f8f9dd51e33221155b68375b66c1c59525a93a8c4a4437012b1e3f9133b4311"
},
"downloads": -1,
"filename": "frigid-1.0.tar.gz",
"has_sig": false,
"md5_digest": "08cf356c91c7036a68836632a1b51eeb",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 20386,
"upload_time": "2024-12-05T03:49:32",
"upload_time_iso_8601": "2024-12-05T03:49:32.878358Z",
"url": "https://files.pythonhosted.org/packages/85/13/fee99c8812583fe531630018d462157d4c7473284e1a5636aab492ae6eb5/frigid-1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-05 03:49:32",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "emcd",
"github_project": "python-frigid",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "frigid"
}