{ "info": { "author": "Erik-Cristian Seulean", "author_email": "eseulean@bloomberg.net", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Operating System :: MacOS :: MacOS X", "Operating System :: Microsoft :: Windows", "Operating System :: POSIX", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development :: Libraries", "Topic :: Software Development :: Testing", "Topic :: Utilities" ], "description": "\n[![Latest version on\nPyPi](https://badge.fury.io/py/attrs-strict.svg)](https://badge.fury.io/py/attrs-strict)\n[![Supported Python\nversions](https://img.shields.io/pypi/pyversions/attrs-strict.svg)](https://pypi.org/project/attrs-strict/)\n[![Travis build\nstatus](https://travis-ci.com/bloomberg/attrs-strict.svg?branch=master)](https://travis-ci.com/bloomberg/attrs-strict.svg?branch=master)\n[![Code style:\nblack](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n# attrs runtime validation\n\n`attrs-strict` is a Python package that contains runtime validation for [`attrs`]((https://github.com/python-attrs/attrs)) data classes based on the types existing in the typing module.\n\n\n## Rationale\nThe purpose of the library is to provide runtime validation for attributes specified in\n[`attrs`](https://www.attrs.org/en/stable/) data classes. The types supported are all the builtin\ntypes and most of the ones defined in the typing library. For Python 2, the typing module is\navailable through the backport found [`here`](https://pypi.org/project/typing/).\n\n## Quick Start\nType enforcement is based on the `type` attribute set on any field specified in an `attrs` dataclass. If the type argument is not specified no validation takes place.\n\n`pip install attrs-strict`\n\n```python\nfrom typing import List\n\nimport attr\n\nfrom attrs_strict import type_validator\n\n>>> @attr.s\n... class SomeClass(object):\n... list_of_numbers = attr.ib(\n... validator=type_validator(),\n... type=List[int]\n... )\n...\n\n>>> sc = SomeClass([1,2,3,4])\n>>> sc\nSomeClass(list_of_numbers=[1, 2, 3, 4])\n\n>>> try:\n... other = SomeClass([1,2,3,'four'])\n... except ValueError as error:\n... print(repr(error))\nattrs_strict._error.AttributeTypeError: list_of_numbers must be\ntyping.List[int] (got four that is a ) in [1, 2, 3, 'four']\n```\n\nNested type exceptions are validated acordingly, and a backtrace to the initial container is maintained to ease with debugging. This means that if an exception occurs because a nested element doesn't have the correct type, the representation of the exception will contain the path to the specific element that caused the exception.\n\n\n```python\nfrom typing import List, Tuple\n\nimport attr\n\nfrom attrs_strict import type_validator\n\n>>> @attr.s\n... class SomeClass(object):\n... names = attr.ib(\n... validator=type_validator(), type=List[Tuple[str, str]]\n... )\n\n>>> sc = SomeClass(names=[('Moo', 'Moo'), ('Zoo',123)])\n\nattrs_strict._error.AttributeTypeError: names must be\n typing.List[typing.Tuple[str, str]] (got 123 that is a ) in\n ('Zoo', 123) in [('Moo', 'Moo'), ('Zoo', 123)]\n```\n\n### What is currently supported ?\n\nCurrently there's support for simple types and types specified in the `typing` module: `List`, `Dict`, `DefaultDict`, `Set`, `Union`, `Tuple` and any combination of them. This means that you can specify nested types like `List[List[Dict[int, str]]]` and the validation would check if attribute has the specific type.\n\n`Callables`, `TypeVars` or `Generics` are not supported yet but there are plans to support this in the future.\n\n## Building\n\nFor development, the project uses `tox` in order to install dependencies, run tests and generate documentation. In order to be able to do this, you need tox `pip install tox` and after that invoke `tox` in the root of the project.\n\n## Installation\n\nRun `pip install attrs-strict` to install the latest stable version from [PyPi](https://pypi.org/project/attrs-strict/). Documentation is hosted on [readthedocs](https://attrs-strict.readthedocs.io/en/latest/).\n\nFor the latest version, on github `pip install git+https://github.com/bloomberg/attrs-strict`.\n\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/bloomberg/attrs-strict", "keywords": "", "license": "Apache 2.0", "maintainer": "", "maintainer_email": "", "name": "attrs-strict", "package_url": "https://pypi.org/project/attrs-strict/", "platform": "", "project_url": "https://pypi.org/project/attrs-strict/", "project_urls": { "Documentation": "https://github.com/bloomberg/attrs-strict/blob/master/README.md#attrs-runtime-validation", "Homepage": "https://github.com/bloomberg/attrs-strict", "Source": "https://github.com/bloomberg/attrs-strict", "Tracker": "https://github.com/bloomberg/attrs-strict/issues" }, "release_url": "https://pypi.org/project/attrs-strict/0.0.4/", "requires_dist": [ "attrs", "typing ; python_version < \"3.5\"" ], "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4", "summary": "Runtime validators for attrs", "version": "0.0.4" }, "last_serial": 5894960, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "7777301275c6e9e58e711d58b9388ee3", "sha256": "556ce11a6926576b0b4d968c29fc994f3b7edd10b4f444f9e13f4471c78952e0" }, "downloads": -1, "filename": "attrs_strict-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "7777301275c6e9e58e711d58b9388ee3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4", "size": 8771, "upload_time": "2019-09-25T13:31:32", "url": "https://files.pythonhosted.org/packages/70/27/b83883f6fadf2223674c4a799b7dbfdd19dc49a2f53100bdf132fafbc8ab/attrs_strict-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "8b9598e168e0336b0b850942f9aac32c", "sha256": "76d2379a1d5d355699a7dc94fed3a8e02f4215ad5293a5adeaa93a2d3de4607d" }, "downloads": -1, "filename": "attrs-strict-0.0.1.tar.gz", "has_sig": false, "md5_digest": "8b9598e168e0336b0b850942f9aac32c", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4", "size": 13884, "upload_time": "2019-09-25T13:31:34", "url": "https://files.pythonhosted.org/packages/62/e0/61f4eeb8258ad6ff95f6bf02deb930491f49229d4b90d59438d66e4abcf6/attrs-strict-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "f847a0bdc4213841e7715cdb230d6bad", "sha256": "597fa3bb0ae6cab221c32ac3af5cc653210aab8c7bcef052577e28619929366a" }, "downloads": -1, "filename": "attrs_strict-0.0.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "f847a0bdc4213841e7715cdb230d6bad", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4", "size": 11146, "upload_time": "2019-09-25T14:10:21", "url": "https://files.pythonhosted.org/packages/d4/63/03d4d544bd3fb5663ec920e8fae6eb4ba6562bb9e22311f25139e71835cd/attrs_strict-0.0.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "64524a6662d3d922383f415a1964784a", "sha256": "b6e6a2e2c29947beedabba42f36414b1e826319fa9099ba0c40d9db9b522a616" }, "downloads": -1, "filename": "attrs-strict-0.0.2.tar.gz", "has_sig": false, "md5_digest": "64524a6662d3d922383f415a1964784a", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4", "size": 15022, "upload_time": "2019-09-25T14:10:23", "url": "https://files.pythonhosted.org/packages/bb/36/38f6683b5647c2ed1b45432ddfbec73143736a8e1bf7cb584a4968251124/attrs-strict-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "70cf8fb6d24d71bb669f2f26e8ad9f98", "sha256": "c94624f50d8aec16f3b7c3a41d79202584f9a871d99f353d248cf8361929f3d7" }, "downloads": -1, "filename": "attrs_strict-0.0.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "70cf8fb6d24d71bb669f2f26e8ad9f98", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4", "size": 11157, "upload_time": "2019-09-26T07:30:20", "url": "https://files.pythonhosted.org/packages/82/40/b23a4cc3983959c44dca4808532c4a62fe2b00117eb39fd8061edf509da1/attrs_strict-0.0.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7b4ca8b1b811a3013586f89eb20ee54c", "sha256": "022b494329a1443e40b0c537e825455dfc92ab8080b3f59cd6fa5613bb5a0f16" }, "downloads": -1, "filename": "attrs-strict-0.0.3.tar.gz", "has_sig": false, "md5_digest": "7b4ca8b1b811a3013586f89eb20ee54c", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4", "size": 15029, "upload_time": "2019-09-26T07:30:21", "url": "https://files.pythonhosted.org/packages/17/9e/cfd76bb1f29fcc95c867df6ddd7d7255c21aeeaf492eca32b74f5deeae15/attrs-strict-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "6156cad4d9147709790b5a667500753c", "sha256": "3a29c8beedd3dcac9cf1eca979cf53bac11b0466e154ee1618bd4d8ab3fe0d0a" }, "downloads": -1, "filename": "attrs_strict-0.0.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "6156cad4d9147709790b5a667500753c", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4", "size": 10499, "upload_time": "2019-09-27T08:59:32", "url": "https://files.pythonhosted.org/packages/c0/a8/44628efed5b43e870a00c49bd4818e32f204f8692809dc2bc717c4799dcf/attrs_strict-0.0.4-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6c3566ff634ae9168ead5cdfc17fd3a8", "sha256": "9f1609efc19ade1545d07a659c22a29f821c96792d906e8ce55db76bba25e052" }, "downloads": -1, "filename": "attrs-strict-0.0.4.tar.gz", "has_sig": false, "md5_digest": "6c3566ff634ae9168ead5cdfc17fd3a8", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4", "size": 14426, "upload_time": "2019-09-27T08:59:34", "url": "https://files.pythonhosted.org/packages/9d/3c/b186aa6704d9c5c6dc01a7e655e509e6dbcda5acef7eaee394300c3c0316/attrs-strict-0.0.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "6156cad4d9147709790b5a667500753c", "sha256": "3a29c8beedd3dcac9cf1eca979cf53bac11b0466e154ee1618bd4d8ab3fe0d0a" }, "downloads": -1, "filename": "attrs_strict-0.0.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "6156cad4d9147709790b5a667500753c", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4", "size": 10499, "upload_time": "2019-09-27T08:59:32", "url": "https://files.pythonhosted.org/packages/c0/a8/44628efed5b43e870a00c49bd4818e32f204f8692809dc2bc717c4799dcf/attrs_strict-0.0.4-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6c3566ff634ae9168ead5cdfc17fd3a8", "sha256": "9f1609efc19ade1545d07a659c22a29f821c96792d906e8ce55db76bba25e052" }, "downloads": -1, "filename": "attrs-strict-0.0.4.tar.gz", "has_sig": false, "md5_digest": "6c3566ff634ae9168ead5cdfc17fd3a8", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4", "size": 14426, "upload_time": "2019-09-27T08:59:34", "url": "https://files.pythonhosted.org/packages/9d/3c/b186aa6704d9c5c6dc01a7e655e509e6dbcda5acef7eaee394300c3c0316/attrs-strict-0.0.4.tar.gz" } ] }