# :recycle: Unwrapper pydantic optional fields :recycle:
Unwrapper stores a **Result** object to implement unpacking of values if they are not **None**. The **BaseModel** object is also a little extended to work with the **Result** object.
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![pypi](https://img.shields.io/pypi/v/unwrap_basemodel_fields.svg)](https://pypi.python.org/pypi/unwrap_basemodel_fields)
[![versions](https://img.shields.io/pypi/pyversions/unwrap_basemodel_fields.svg)](https://github.com/luwqz1/unwrap_basemodel_fields)
[![license](https://img.shields.io/github/license/luwqz1/unwrap_basemodel_fields.svg)](https://github.com/luwqz1/unwrap_basemodel_fields/blob/main/LICENSE)
# :star: A simple example :star:
```python
from unwrapper import BaseModel, Result
class User(BaseModel):
name: Result[str]
age: int
data = {
"age": 20
}
user = User(**data)
#> User(name=Result(None), age=20)
print("Hello", user.name.unwrap(error_msg="What's your name?"), "!")
#> ValueError: What's your name?
```
# :book: Documentation :book:
* In :ru: [**Russian**](https://github.com/luwqz1/unwrap_basemodel_fields/blob/main/docs/RU.md) :ru:
* In :us: [**English**](https://github.com/luwqz1/unwrap_basemodel_fields/blob/main/docs/EN.md) :us:
Raw data
{
"_id": null,
"home_page": "https://github.com/luwqz1/unwrap_basemodel_fields",
"name": "unwrap-basemodel-fields",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8,<4.0",
"maintainer_email": "",
"keywords": "python,uwrapping,optional handle,basemodel fields",
"author": "Georgy howl",
"author_email": "howluwqz1@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/82/fa/7d68291efd5aa5341922bd6c9e54eb4e1fccfeb9810425964fc1c63967f6/unwrap_basemodel_fields-0.5.2.tar.gz",
"platform": null,
"description": "# :recycle: Unwrapper pydantic optional fields :recycle:\n\n\nUnwrapper stores a **Result** object to implement unpacking of values if they are not **None**. The **BaseModel** object is also a little extended to work with the **Result** object.\n\n\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![pypi](https://img.shields.io/pypi/v/unwrap_basemodel_fields.svg)](https://pypi.python.org/pypi/unwrap_basemodel_fields)\n[![versions](https://img.shields.io/pypi/pyversions/unwrap_basemodel_fields.svg)](https://github.com/luwqz1/unwrap_basemodel_fields)\n[![license](https://img.shields.io/github/license/luwqz1/unwrap_basemodel_fields.svg)](https://github.com/luwqz1/unwrap_basemodel_fields/blob/main/LICENSE)\n\n\n# :star: A simple example :star:\n```python\nfrom unwrapper import BaseModel, Result\n\nclass User(BaseModel):\n name: Result[str]\n age: int\n\ndata = {\n \"age\": 20\n}\nuser = User(**data)\n#> User(name=Result(None), age=20)\nprint(\"Hello\", user.name.unwrap(error_msg=\"What's your name?\"), \"!\")\n#> ValueError: What's your name?\n```\n\n# :book: Documentation :book:\n* In :ru: [**Russian**](https://github.com/luwqz1/unwrap_basemodel_fields/blob/main/docs/RU.md) :ru:\n* In :us: [**English**](https://github.com/luwqz1/unwrap_basemodel_fields/blob/main/docs/EN.md) :us:\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Unwrapper stores a Result object to implement unpacking of values if they are not None. The BaseModel object is also a little extended to work with the Result object.",
"version": "0.5.2",
"split_keywords": [
"python",
"uwrapping",
"optional handle",
"basemodel fields"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "8697b6d299e6fa2e1599c62364b156387a987fb03775bdbbbdbb0f9b79332fd9",
"md5": "b35c115ae00edb5dd5a3755ea77421d6",
"sha256": "7ecb9425da92d83b9f6675e71f0bc01be9eca67a1ec206a443da5c064db6ca0f"
},
"downloads": -1,
"filename": "unwrap_basemodel_fields-0.5.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b35c115ae00edb5dd5a3755ea77421d6",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8,<4.0",
"size": 4304,
"upload_time": "2023-03-23T18:10:41",
"upload_time_iso_8601": "2023-03-23T18:10:41.582232Z",
"url": "https://files.pythonhosted.org/packages/86/97/b6d299e6fa2e1599c62364b156387a987fb03775bdbbbdbb0f9b79332fd9/unwrap_basemodel_fields-0.5.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "82fa7d68291efd5aa5341922bd6c9e54eb4e1fccfeb9810425964fc1c63967f6",
"md5": "88678f348e111b4e93413a03bfe4f2d4",
"sha256": "6a4cfd3a7fe9ac86cb0af23d8a46b6d358e512739db152c6a3743c71db26ed06"
},
"downloads": -1,
"filename": "unwrap_basemodel_fields-0.5.2.tar.gz",
"has_sig": false,
"md5_digest": "88678f348e111b4e93413a03bfe4f2d4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8,<4.0",
"size": 4112,
"upload_time": "2023-03-23T18:10:42",
"upload_time_iso_8601": "2023-03-23T18:10:42.770183Z",
"url": "https://files.pythonhosted.org/packages/82/fa/7d68291efd5aa5341922bd6c9e54eb4e1fccfeb9810425964fc1c63967f6/unwrap_basemodel_fields-0.5.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-03-23 18:10:42",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "luwqz1",
"github_project": "unwrap_basemodel_fields",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "unwrap-basemodel-fields"
}