{"id":26579932,"url":"https://github.com/obriencj/python-proxytype","last_synced_at":"2025-10-18T01:49:02.558Z","repository":{"id":232855451,"uuid":"785324650","full_name":"obriencj/python-proxytype","owner":"obriencj","description":"Static analysis typing support for dynamic proxy classes","archived":false,"fork":false,"pushed_at":"2024-07-06T18:05:14.000Z","size":49,"stargazers_count":1,"open_issues_count":4,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-27T18:18:17.779Z","etag":null,"topics":["mypy-plugins"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/obriencj.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-04-11T16:53:54.000Z","updated_at":"2025-06-17T14:24:51.000Z","dependencies_parsed_at":"2024-05-10T22:42:57.029Z","dependency_job_id":"0c9aa51d-3055-4d68-9eba-bf4f0c119a85","html_url":"https://github.com/obriencj/python-proxytype","commit_stats":null,"previous_names":["obriencj/python-proxytype"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/obriencj/python-proxytype","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obriencj%2Fpython-proxytype","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obriencj%2Fpython-proxytype/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obriencj%2Fpython-proxytype/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obriencj%2Fpython-proxytype/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/obriencj","download_url":"https://codeload.github.com/obriencj/python-proxytype/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obriencj%2Fpython-proxytype/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264247847,"owners_count":23579054,"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":["mypy-plugins"],"created_at":"2025-03-23T06:29:33.181Z","updated_at":"2025-10-05T06:44:09.962Z","avatar_url":"https://github.com/obriencj.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Overview\n\n`preoccupied.proxytype` is a [Python] package providing a [MyPy]\nplugin and a class decorator for triggering that plugin. The decorator\ncan be used to indicate that a decorated class should be considered\nduring static analysis to posess all of the methods from another\nclass.\n\n[python]: https://python.org\n\n[MyPy]: https://mypy-lang.org\n\nThis pattern is distinct from inheritance, in that it will also apply\na transformation to the return type of the copied methods. It is valid\nfor this transformed return type to be incompatible with the original\ntemplate class's method signature.\n\nThis is useful in situations where a dynamic class wraps or proxies\nits calls to another instance, optionally decorating them in the\nprocess.\n\nThe class decorator has no behavior at runtime -- it does not\nimplement the proxying. It is only there to provide a way to declare\nsuch behavior during static analysis.\n\n\n## Installation\n\nInstall from the latest PyPI release\n\n```bash\npip install --user preoccupied.proxytype\n```\n\nInstall from a git checkout\n\n```bash\nmake install\n```\n\n\n## Enable plugin\n\nAt runtime the proxytype class decorator does not introduce a MyPy\ndependency. However in order for it to operate during MyPy's static\nanalysis checks the plugin must be enabled. For example in `setup.cfg`\n\n```ini filename=setup.cfg\n[mypy]\nplugins =\n  preoccupied.proxytype\n```\n\n\n## Usage of proxytype\n\nAt runtime the proxytype class decorator has no impact. During static\nanalysis via MyPy the proxytype class decorator can be used to\nvirtually annotate that class with the methods from the originating\ntype. Methods brought across to the decorated type will have their\nself argument type updated, and can optionally have their return type\nmodified to be a wrapped generic around the original return type.\n\nFor example:\n\n```python\nfrom preoccupied.proxytype import proxytype\n\n\nclass ClientSession:\n    def doSomething(self, how_many: int, etc: Any) -\u003e List[int]:\n        ...\n\n    def doAnother(self, wut: Any, **kwds: Any) -\u003e bool:\n        ...\n\n    def getName(self) -\u003e str:\n        ...\n\n\nRT = TypeVar(\"RT\")\n\nclass DelayResult(Generic[RT]):\n    resultValue: RT\n\n\n@proxytype(ClientSession, DelayResult)\nclass DelayClientSession:\n    def getName(self) -\u003e str:\n        ...\n```\n\nThis will cause static analysys via MyPy of the `DelayClientSession`\nto appear as if it had been declared as:\n\n```python\nclass DelayClientSession:\n    def doSomething(self, how_many: int, etc: Any) -\u003e DelayResult[List[int]]:\n        ...\n\n    def doAnother(self, wut: Any, **kwds: Any) -\u003e DelayResult[bool]:\n        ...\n\n    def getName(self) -\u003e str:\n        ...\n```\n\n\n## Contact\n\nauthor: Christopher O'Brien  \u003cobriencj@preoccupied.net\u003e\n\noriginal git repository: \u003chttps://github.com/obriencj/python-proxytype\u003e\n\npypi project: \u003chttps://pypi.org/project/preoccupied.proxytype\u003e\n\n\n## License\n\nThis library is free software; you can redistribute it and/or modify\nit under the terms of the GNU Lesser General Public License as\npublished by the Free Software Foundation; either version 3 of the\nLicense, or (at your option) any later version.\n\nThis library is distributed in the hope that it will be useful, but\nWITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\nLesser General Public License for more details.\n\nYou should have received a copy of the GNU Lesser General Public\nLicense along with this library; if not, see\n\u003chttp://www.gnu.org/licenses/\u003e.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fobriencj%2Fpython-proxytype","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fobriencj%2Fpython-proxytype","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fobriencj%2Fpython-proxytype/lists"}