{"id":24638223,"url":"https://github.com/miyamo2/py_nullable","last_synced_at":"2025-03-20T09:35:01.140Z","repository":{"id":92586012,"uuid":"596154076","full_name":"miyamo2/py_nullable","owner":"miyamo2","description":"Python's None Wrapper, inspired by java.util.Optional","archived":false,"fork":false,"pushed_at":"2024-07-10T06:52:55.000Z","size":2869,"stargazers_count":2,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-14T23:37:46.395Z","etag":null,"topics":["null-safety","nullable","python","python3"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/py-nullable/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/miyamo2.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-02-01T15:26:22.000Z","updated_at":"2024-05-23T11:32:52.000Z","dependencies_parsed_at":"2023-09-12T02:26:29.277Z","dependency_job_id":"44cf47ff-92b3-4987-8956-09a3fbd95ab5","html_url":"https://github.com/miyamo2/py_nullable","commit_stats":null,"previous_names":["miyamo2/py_nullable","miyamo2theppl/py_nullable"],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miyamo2%2Fpy_nullable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miyamo2%2Fpy_nullable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miyamo2%2Fpy_nullable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miyamo2%2Fpy_nullable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/miyamo2","download_url":"https://codeload.github.com/miyamo2/py_nullable/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244586472,"owners_count":20476946,"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":["null-safety","nullable","python","python3"],"created_at":"2025-01-25T10:13:29.421Z","updated_at":"2025-03-20T09:35:01.121Z","avatar_url":"https://github.com/miyamo2.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# py_nullable\n\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/py_nullable?logo=python\u0026logoColor=yellow)](https://img.shields.io/pypi/pyversions/py_nullable?logo=python\u0026logoColor=yellow)\n[![PyPI](https://img.shields.io/pypi/v/py_nullable?color=blue\u0026logo=pypi\u0026logoColor=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\u0026logo=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\u0026units=international_system\u0026left_color=blue\u0026right_color=yellow\u0026left_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) -\u003e 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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiyamo2%2Fpy_nullable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmiyamo2%2Fpy_nullable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiyamo2%2Fpy_nullable/lists"}