{"id":20663344,"url":"https://github.com/rustedpy/maybe","last_synced_at":"2025-04-04T19:15:11.414Z","repository":{"id":190910708,"uuid":"679960341","full_name":"rustedpy/maybe","owner":"rustedpy","description":"NOT MAINTAINED - A simple Rust like Option type for Python 3. Fully type annotated.","archived":false,"fork":false,"pushed_at":"2024-12-01T09:44:13.000Z","size":43,"stargazers_count":71,"open_issues_count":10,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-28T18:15:27.586Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/rustedpy/result/issues/201","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/rustedpy.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-18T02:47:29.000Z","updated_at":"2025-03-19T18:09:05.000Z","dependencies_parsed_at":"2024-06-02T00:45:38.241Z","dependency_job_id":"5cdf85b0-157e-4d99-b265-5227d84e743b","html_url":"https://github.com/rustedpy/maybe","commit_stats":null,"previous_names":["rustedpy/maybe"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rustedpy%2Fmaybe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rustedpy%2Fmaybe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rustedpy%2Fmaybe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rustedpy%2Fmaybe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rustedpy","download_url":"https://codeload.github.com/rustedpy/maybe/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247234923,"owners_count":20905854,"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":[],"created_at":"2024-11-16T19:17:30.963Z","updated_at":"2025-04-04T19:15:11.385Z","avatar_url":"https://github.com/rustedpy.png","language":"Python","readme":"# Maybe\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/rustedpy-maybe?logo=python\u0026logoColor=white)](https://pypi.org/project/rustedpy-maybe/)\n[![PyPI](https://img.shields.io/pypi/v/rustedpy-maybe)](https://pypi.org/project/rustedpy-maybe/)\n[![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/rustedpy/maybe/ci.yml?branch=master)](https://github.com/rustedpy/maybe/actions/workflows/ci.yml?query=branch%3Amaster)\n[![Checked with mypy](https://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)\n[![Coverage](https://codecov.io/gh/rustedpy/maybe/branch/master/graph/badge.svg)](https://codecov.io/gh/rustedpy/maybe)\n\nA simple Maybe (Option) type for Python 3 [inspired by Rust](\nhttps://doc.rust-lang.org/std/option/), fully type annotated.\n\n## Installation\n\nLatest release:\n\n```sh\npip install rustedpy-maybe\n```\n\nLatest GitHub `master` branch version:\n\n```sh\npip install git+https://github.com/rustedpy/maybe\n```\n\nThere are no dependencies outside of the Python standard library.  However, if\nyou wish to use the `Result` conversion methods (see examples in the next\nsection), you will need to install the `result` extra.\n\nIn this case, rather than installing via one of the commands above, you can\ninstall the package with the `result` extra either from the latest release:\n\n```sh\npip install rustedpy-maybe[result]\n```\n\nor from the GitHub `master` branch:\n\n```sh\npip install git+https://github.com/rustedpy/maybe[result]\n```\n\n## Summary\n\n**Experimental. API subject to change.**\n\nThe idea is that a possible value can be either `Some(value)` or `Nothing()`,\nwith a way to differentiate between the two. `Some` and `Nothing` are both\nclasses encapsulating a possible value.\n\nExample usage:\n\n```python\nfrom maybe import Nothing, Some\n\no = Some('yay')\nn = Nothing()\nassert o.unwrap_or_else(str.upper) == 'yay'\nassert n.unwrap_or_else(lambda: 'default') == 'default'\n```\n\nThere are some methods that support conversion from a `Maybe` to a `Result` type\nin the [result library](https://github.com/rustedpy/result/).  If you wish to\nleverage these methods, you must install the `result` extra as described in the\ninstallation section.\n\nExample usage:\n\n```python\nfrom maybe import Nothing, Some\nfrom result import Ok, Err\n\no = Some('yay')\nn = Nothing()\nassert o.ok_or('error') == Ok('yay')\nassert o.ok_or_else(lambda: 'error') == Ok('yay')\nassert n.ok_or('error') == Err('error')\nassert n.ok_or_else(lambda: 'error') == Err('error')\n```\n\n## Contributing\n\nThese steps should work on any Unix-based system (Linux, macOS, etc) with Python\nand `make` installed. On Windows, you will need to refer to the Python\ndocumentation (linked below) and reference the `Makefile` for commands to run\nfrom the non-unix shell you're using on Windows.\n\n1. Setup and activate a virtual environment.  See [Python docs][pydocs-venv] for\n   more information about virtual environments and setup.\n1. Run `make install` to install dependencies\n1. Switch to a new git branch and make your changes\n1. Test your changes:\n   - `make test`\n   - `make lint`\n   - You can also start a Python REPL and import `maybe`\n1. Update documentation\n   - Edit any relevant docstrings, markdown files\n   - Run `make docs`\n1. Add an entry to the [changelog](./CHANGELOG.md)\n1. Git commit all your changes and create a new PR.\n\n[pydocs-venv]: https://docs.python.org/3/library/venv.html\n\n## License\n\nMIT License\n","funding_links":[],"categories":["Awesome Functional Python"],"sub_categories":["Libraries"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frustedpy%2Fmaybe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frustedpy%2Fmaybe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frustedpy%2Fmaybe/lists"}