{"id":20812231,"url":"https://github.com/curegit/reification","last_synced_at":"2026-03-05T03:04:43.589Z","repository":{"id":163484065,"uuid":"638137885","full_name":"curegit/reification","owner":"curegit","description":"Reified generics in Python to get type parameters at runtime","archived":false,"fork":false,"pushed_at":"2026-03-02T08:23:42.000Z","size":85,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-03-02T12:31:25.675Z","etag":null,"topics":["generics","parametric-polymorphism","python","reflection","reification","typing"],"latest_commit_sha":null,"homepage":"https://curegit.github.io/reification/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"wtfpl","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/curegit.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-05-09T06:56:36.000Z","updated_at":"2026-03-02T08:23:46.000Z","dependencies_parsed_at":"2024-04-24T17:58:36.610Z","dependency_job_id":"fa8fe43c-cc5a-44c1-bb7a-98cdd0136d41","html_url":"https://github.com/curegit/reification","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/curegit/reification","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/curegit%2Freification","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/curegit%2Freification/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/curegit%2Freification/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/curegit%2Freification/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/curegit","download_url":"https://codeload.github.com/curegit/reification/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/curegit%2Freification/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30107658,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T01:39:18.192Z","status":"online","status_checked_at":"2026-03-05T02:00:06.710Z","response_time":93,"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":["generics","parametric-polymorphism","python","reflection","reification","typing"],"created_at":"2024-11-17T20:51:23.091Z","updated_at":"2026-03-05T03:04:43.578Z","avatar_url":"https://github.com/curegit.png","language":"Python","readme":"# Reification (Python library)\n\n[![Unit Tests](https://github.com/curegit/reification/actions/workflows/test.yml/badge.svg)](https://github.com/curegit/reification/actions/workflows/test.yml)\n\nReified generics in Python to get type parameters at runtime\n\n```py\nfrom reification import Reified\n\n\nclass ReifiedList[T](Reified, list[T]):\n    pass\n\n\nxs = ReifiedList[int](range(10))\nprint(xs)  # [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\nprint(xs.targ)  # \u003cclass 'int'\u003e\n```\n\nSee the detailed documentation at \u003chttps://curegit.github.io/reification/\u003e.\n\n## Requirements\n\n- Python \u003e= 3.12\n\nThis library is written in pure Python and does not require any external modules.\n\n## Installation\n\n```sh\npip install reification\n```\n\n## Example Usage: Type-Checked Generic Stack\n\n```py\nfrom reification import Reified\n\n\nclass ReifiedStack[T](Reified):\n    def __init__(self) -\u003e None:\n        super().__init__()\n        self.items: list[T] = []\n\n    def push(self, item: T) -\u003e None:\n        # We can do runtime check\n        if isinstance(item, self.targ):\n            self.items.append(item)\n        else:\n            raise TypeError()\n\n    def pop(self) -\u003e T:\n        if self.items:\n            return self.items.pop()\n        else:\n            raise IndexError(\"pop from empty stack\")\n\n\nstack = ReifiedStack[str]()\nstack.push(\"spam\")  # OK\nstack.push(42)  # raises TypeError\n```\n\nThe `ReifiedStack` class created here is generic and derived from the `Reified` base class, and implements a simple stack with `push` and `pop` methods.\n\nIn the `push` method, we are checking at runtime if the item being pushed is of the specified generic type (this type is accessible via the `targ` attribute inherited from `Reified`).\nIf the type of the item does not match, a `TypeError` is raised.\n\nIn the example usage, we create an instance of the ReifiedStack class with `str` as the type argument. When we try to push a string `\"spam\"`, the item is accepted since it matches the stack's specified type argument.\nHowever, when we try to push an integer `42`, a `TypeError` is raised because the type of the item does not match the stack's type argument.\n\nThis demonstrates the use of reified generics in Python where we can have runtime access to the type parameters, enabling us to type check dynamically at runtime.\nThis is useful in situations where we need to enforce type safety in our code or use type information at runtime.\n\n## API\n\nSee the full API reference at \u003chttps://curegit.github.io/reification/reference/\u003e.\n\n## License\n\nWTFPL\n\nCopyright (C) 2023 curegit\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcuregit%2Freification","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcuregit%2Freification","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcuregit%2Freification/lists"}