Name | py-nullable JSON |
Version |
0.3.2
JSON |
| download |
home_page | |
Summary | Python's None Wrapper, inspired by java.util.Optional |
upload_time | 2023-09-04 16:15:45 |
maintainer | |
docs_url | None |
author | miyamo2theppl |
requires_python | <3.12,>=3.7 |
license | MIT License Copyright (c) 2023 miyamo2theppl Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
none
null
nullable
java
null safety
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# py_nullable
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/py_nullable?logo=python&logoColor=yellow)](https://img.shields.io/pypi/pyversions/py_nullable?logo=python&logoColor=yellow)
[![PyPI](https://img.shields.io/pypi/v/py_nullable?color=blue&logo=pypi&logoColor=yellow)](https://pypi.org/project/py-nullable?latest)
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/miyamo2theppl/py_nullable)](https://img.shields.io/github/v/release/miyamo2theppl/py_nullable)
[![PyPI - Wheel](https://img.shields.io/pypi/wheel/py-nullable)](https://img.shields.io/pypi/wheel/py-nullable)
[![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/miyamo2theppl/py_nullable/release.yaml?event=release&logo=github%20actions)](https://github.com/miyamo2theppl/py_nullable/actions?query=workflow%3Arelease)
[![Coverage](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/miyamo2theppl/15e55b51670ba3c88767f9402215e901/raw/pytest-coverage-comment.json)](https://github.com/miyamo2theppl/py_nullable/actions?query=workflow%3Atest)
[![GitHub](https://img.shields.io/github/license/miyamo2theppl/py_nullable)](https://img.shields.io/github/license/miyamo2theppl/py_nullable)
[![Downloads](https://static.pepy.tech/personalized-badge/py-nullable?period=total&units=international_system&left_color=blue&right_color=yellow&left_text=Downloads)](https://pepy.tech/project/py-nullable)
## Introduction
Python's None Wrapper, inspired by java.util.Optional
[Document(latest version only)](https://miyamo2theppl.github.io/py_nullable/)
## Getting Started
### Installing
install from PyPI with:
```sh
python -m pip install py_nullable
```
install from source with:
```sh
git clone https://github.com/miyamo2theppl/py_nullable.git
cd py_nullable
python -m pip install .
```
### Simple Usage
if you want to get value.
```python
from py_nullable import Nullable
nullable: Nullable[str] = Nullable[str]("some string")
if nullable.isPresent():
print(nullable.get()) # Prints some string
```
if you want to generate a new Nullable from an existing Nullable with the mapping function.
```python
from typing import Callable
from py_nullable import Nullable
nullable: Nullable[str] = Nullable[str]("1234")
callback: Callable[[str], int] = lambda x: int(x) * 2
result: Nullable[int] = nullable.map(callback)
print(result.get()) # Prints 2468
```
if you want to refactor the return value from Optional[T] to Nullable[T].
```python
from yourpackage import YourClass
from py_nullable import Nullable, nullable_wrap
in_memory_db: dict[str, YourClass] = {"A001": YourClass("foo")}
@nullable_wrap
def find_by_id(id: str) -> Optional[YourClass]:
return in_memory_db.get(id)
nullable: Nullable[YourClass] = find_by_id("B001")
print(nullable.isEmpty()) # Prints True
```
## Contributing
### Create a feature branch
```sh
git checkout -b feature_{example}
```
### Set up your environment
```sh
python -m venv .venv
.venv/bin/activate
pip install -r dev_requirements.txt
pip install -e .
```
### Running Tests
```sh
pytest --cov py_nullable --cov-branch --cov-report=html
```
Raw data
{
"_id": null,
"home_page": "",
"name": "py-nullable",
"maintainer": "",
"docs_url": null,
"requires_python": "<3.12,>=3.7",
"maintainer_email": "",
"keywords": "None,null,nullable,Java,Null Safety",
"author": "miyamo2theppl",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/c3/c1/b07c12e0f0b79dba194940d220a18e9a1a62da7272ba1ee932737bd53a80/py_nullable-0.3.2.tar.gz",
"platform": null,
"description": "# py_nullable\n\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/py_nullable?logo=python&logoColor=yellow)](https://img.shields.io/pypi/pyversions/py_nullable?logo=python&logoColor=yellow)\n[![PyPI](https://img.shields.io/pypi/v/py_nullable?color=blue&logo=pypi&logoColor=yellow)](https://pypi.org/project/py-nullable?latest)\n[![GitHub release (latest by date)](https://img.shields.io/github/v/release/miyamo2theppl/py_nullable)](https://img.shields.io/github/v/release/miyamo2theppl/py_nullable)\n[![PyPI - Wheel](https://img.shields.io/pypi/wheel/py-nullable)](https://img.shields.io/pypi/wheel/py-nullable)\n[![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/miyamo2theppl/py_nullable/release.yaml?event=release&logo=github%20actions)](https://github.com/miyamo2theppl/py_nullable/actions?query=workflow%3Arelease)\n[![Coverage](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/miyamo2theppl/15e55b51670ba3c88767f9402215e901/raw/pytest-coverage-comment.json)](https://github.com/miyamo2theppl/py_nullable/actions?query=workflow%3Atest)\n[![GitHub](https://img.shields.io/github/license/miyamo2theppl/py_nullable)](https://img.shields.io/github/license/miyamo2theppl/py_nullable)\n[![Downloads](https://static.pepy.tech/personalized-badge/py-nullable?period=total&units=international_system&left_color=blue&right_color=yellow&left_text=Downloads)](https://pepy.tech/project/py-nullable)\n\n## Introduction\n\nPython's None Wrapper, inspired by java.util.Optional\n\n[Document(latest version only)](https://miyamo2theppl.github.io/py_nullable/)\n\n## Getting Started\n\n### Installing\n\ninstall from PyPI with:\n\n```sh\npython -m pip install py_nullable\n```\n\ninstall from source with:\n\n```sh\ngit clone https://github.com/miyamo2theppl/py_nullable.git\ncd py_nullable\npython -m pip install .\n```\n\n### Simple Usage\n\nif you want to get value.\n\n```python\nfrom py_nullable import Nullable\n\nnullable: Nullable[str] = Nullable[str](\"some string\")\nif nullable.isPresent():\n print(nullable.get()) # Prints some string\n```\n\nif you want to generate a new Nullable from an existing Nullable with the mapping function.\n\n```python\nfrom typing import Callable\nfrom py_nullable import Nullable\n\nnullable: Nullable[str] = Nullable[str](\"1234\")\n\ncallback: Callable[[str], int] = lambda x: int(x) * 2\nresult: Nullable[int] = nullable.map(callback)\n\nprint(result.get()) # Prints 2468\n```\n\nif you want to refactor the return value from Optional[T] to Nullable[T].\n\n```python\nfrom yourpackage import YourClass\nfrom py_nullable import Nullable, nullable_wrap\n\n\nin_memory_db: dict[str, YourClass] = {\"A001\": YourClass(\"foo\")}\n\n\n@nullable_wrap\ndef find_by_id(id: str) -> Optional[YourClass]:\n return in_memory_db.get(id)\n\n\nnullable: Nullable[YourClass] = find_by_id(\"B001\")\nprint(nullable.isEmpty()) # Prints True\n```\n\n## Contributing\n\n### Create a feature branch\n\n```sh\ngit checkout -b feature_{example}\n```\n\n### Set up your environment\n\n```sh\npython -m venv .venv\n.venv/bin/activate\npip install -r dev_requirements.txt\npip install -e .\n```\n\n### Running Tests\n\n```sh\npytest --cov py_nullable --cov-branch --cov-report=html\n```\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2023 miyamo2theppl Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
"summary": "Python's None Wrapper, inspired by java.util.Optional",
"version": "0.3.2",
"project_urls": {
"repository": "https://github.com/miyamo2theppl/py_nullable.git"
},
"split_keywords": [
"none",
"null",
"nullable",
"java",
"null safety"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "8eaca8c3f7963388d325fd554b29b8aa99ce9e6a528c099d1b2d1942f9664401",
"md5": "5f9f2ea4040b15a381189211bfdba684",
"sha256": "852b6364536fee34c5310164ed951775b9b2c61847e8dcec6e893fc8686934b9"
},
"downloads": -1,
"filename": "py_nullable-0.3.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5f9f2ea4040b15a381189211bfdba684",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<3.12,>=3.7",
"size": 9018,
"upload_time": "2023-09-04T16:15:43",
"upload_time_iso_8601": "2023-09-04T16:15:43.817471Z",
"url": "https://files.pythonhosted.org/packages/8e/ac/a8c3f7963388d325fd554b29b8aa99ce9e6a528c099d1b2d1942f9664401/py_nullable-0.3.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "c3c1b07c12e0f0b79dba194940d220a18e9a1a62da7272ba1ee932737bd53a80",
"md5": "20c2802a45ad49514d14e99b343fae54",
"sha256": "dcc92f74f68400682fac3f45473165942cdc60414d4d7c3c743a8569dfd09750"
},
"downloads": -1,
"filename": "py_nullable-0.3.2.tar.gz",
"has_sig": false,
"md5_digest": "20c2802a45ad49514d14e99b343fae54",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<3.12,>=3.7",
"size": 10730,
"upload_time": "2023-09-04T16:15:45",
"upload_time_iso_8601": "2023-09-04T16:15:45.047467Z",
"url": "https://files.pythonhosted.org/packages/c3/c1/b07c12e0f0b79dba194940d220a18e9a1a62da7272ba1ee932737bd53a80/py_nullable-0.3.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-09-04 16:15:45",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "miyamo2theppl",
"github_project": "py_nullable",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "py-nullable"
}