{"id":31847021,"url":"https://github.com/likeinlife/light-types","last_synced_at":"2025-10-12T09:18:38.043Z","repository":{"id":250330801,"uuid":"834176610","full_name":"likeinlife/light-types","owner":"likeinlife","description":"Create types that respect the invariant. \"Parse, don't validate\"","archived":false,"fork":false,"pushed_at":"2024-08-16T20:36:10.000Z","size":39,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-11T05:14:19.425Z","etag":null,"topics":["phantom-types","python3","types","value-object"],"latest_commit_sha":null,"homepage":"","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/likeinlife.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":"2024-07-26T15:28:46.000Z","updated_at":"2024-08-16T20:36:14.000Z","dependencies_parsed_at":"2024-07-26T16:31:14.105Z","dependency_job_id":null,"html_url":"https://github.com/likeinlife/light-types","commit_stats":null,"previous_names":["likeinlife/light-types"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/likeinlife/light-types","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/likeinlife%2Flight-types","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/likeinlife%2Flight-types/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/likeinlife%2Flight-types/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/likeinlife%2Flight-types/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/likeinlife","download_url":"https://codeload.github.com/likeinlife/light-types/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/likeinlife%2Flight-types/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279010948,"owners_count":26084837,"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","status":"online","status_checked_at":"2025-10-12T02:00:06.719Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["phantom-types","python3","types","value-object"],"created_at":"2025-10-12T09:18:36.726Z","updated_at":"2025-10-12T09:18:38.038Z","avatar_url":"https://github.com/likeinlife.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Light Types\n\n[![image](https://img.shields.io/pypi/v/light-types.svg)](https://pypi.python.org/pypi/light-types)\n[![codecov](https://codecov.io/gh/likeinlife/light-types/graph/badge.svg?token=7QUSPNC4CQ)](https://codecov.io/gh/likeinlife/light-types)\n[![Rye](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/rye/main/artwork/badge.json)](https://rye.astral.sh)\n[![image](https://img.shields.io/pypi/l/light-types.svg)](https://github.com/likeinlife/light-types/blob/main/LICENSE)\n\u003ca href=\"http://mypy-lang.org/\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/badge/mypy-checked-1F5082.svg\" alt=\"Mypy checked\"\u003e\u003c/a\u003e\n[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)\n[![image](https://img.shields.io/pypi/pyversions/light-types.svg)](https://pypi.python.org/pypi/light-types)\n\n\"Parse, don't validate\"\n\nCompatible with PydanticV2\n\nInspired by [Phantom types](https://github.com/antonagestam/phantom-types/)\n\n# Examples\n\n## Sample\n\n```python\nfrom light_types import LightType\n\n\nclass StartsWithString(str, LightType):\n    @classmethod\n    def validate(cls, value: str) -\u003e bool:\n        return value.startswith(\"String\")\n```\n\n## With Pydantic\n\n```python\nfrom light_types import LightType\n\n\nclass StartsWithString(str, LightType):\n    @classmethod\n    def validate(cls, value: str) -\u003e bool:\n        return value.startswith(\"String\")\n\nclass MyModel(BaseModel):\n    value: StartsWithString\n\nassert TypeAdapter(MyModel).validate_python({\"value\": \"StringOk\"})\n```\n\n## QLightType\n\n```python\nfrom light_types import QLightType, NumericQ\n\nclass NumericBetween5And10(int, QLightType):\n    validator = (NumericQ() \u003e 5).custom(lambda n: n \u003c 10)\n```\n\n```python\nfrom light_types import QLightType, StringQ\n\nclass StartsWithString(str, QLightType):\n    validator = StringQ().startswith(\"String\")\n```\n\n```python\nfrom light_types import QLightType, StringQ\n\nclass StringWith2O(str, QLightType):\n    validator = StringQ().startswith(\"String\") \u0026 StringQ().custom(lambda s: s.count(\"o\") \u003e= 2)\n```\n\n```python\nfrom light_types import QLightType, StringQ\n\nclass StringWith2O(str, QLightType):\n    validator = StringQ().startswith(\"String\") | ~StringQ().custom(lambda s: s.count(\"o\") \u003e= 2)\n```\n\n```python\nfrom light_types import QLightType, StringQ, LengthQ\n\nclass StringWith2O(str, QLightType):\n    validator = StringQ().startswith(\"foo\") \u0026 (LengthQ[str]() \u003e 5)\n```\n\n# Tests, linting, formatting\n\n- `rye test | lint | fmt`","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flikeinlife%2Flight-types","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flikeinlife%2Flight-types","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flikeinlife%2Flight-types/lists"}