{"id":34095300,"url":"https://github.com/luxuncang/typefire","last_synced_at":"2026-04-09T00:31:09.520Z","repository":{"id":62585946,"uuid":"460388937","full_name":"luxuncang/typefire","owner":"luxuncang","description":"基于类型注解的自定义类型转换，可用于拓展 fire 解析类型","archived":false,"fork":false,"pushed_at":"2022-07-25T05:02:57.000Z","size":52,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-16T18:55:38.846Z","etag":null,"topics":["fire-python","hints"],"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/luxuncang.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}},"created_at":"2022-02-17T10:36:34.000Z","updated_at":"2022-03-27T16:51:57.000Z","dependencies_parsed_at":"2022-11-03T22:07:46.699Z","dependency_job_id":null,"html_url":"https://github.com/luxuncang/typefire","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/luxuncang/typefire","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luxuncang%2Ftypefire","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luxuncang%2Ftypefire/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luxuncang%2Ftypefire/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luxuncang%2Ftypefire/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luxuncang","download_url":"https://codeload.github.com/luxuncang/typefire/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luxuncang%2Ftypefire/sbom","scorecard":{"id":606140,"data":{"date":"2025-08-11","repo":{"name":"github.com/luxuncang/typefire","commit":"8eb16eb7a0dce22218ee17f399b7afb08786f253"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.9,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:41: update your workflow using https://app.stepsecurity.io/secureworkflow/luxuncang/typefire/codeql-analysis.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:45: update your workflow using https://app.stepsecurity.io/secureworkflow/luxuncang/typefire/codeql-analysis.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:56: update your workflow using https://app.stepsecurity.io/secureworkflow/luxuncang/typefire/codeql-analysis.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:70: update your workflow using https://app.stepsecurity.io/secureworkflow/luxuncang/typefire/codeql-analysis.yml/main?enable=pin","Info:   0 out of   4 GitHub-owned GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":9,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Info: jobLevel 'actions' permission set to 'read': .github/workflows/codeql-analysis.yml:28","Info: jobLevel 'contents' permission set to 'read': .github/workflows/codeql-analysis.yml:29","Warn: no topLevel permission defined: .github/workflows/codeql-analysis.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"SAST","score":10,"reason":"SAST tool detected: CodeQL","details":["Info: SAST configuration detected: CodeQL","Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-21T01:38:03.119Z","repository_id":62585946,"created_at":"2025-08-21T01:38:03.119Z","updated_at":"2025-08-21T01:38:03.119Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31579813,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T14:31:17.711Z","status":"ssl_error","status_checked_at":"2026-04-08T14:31:17.202Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["fire-python","hints"],"created_at":"2025-12-14T15:11:27.765Z","updated_at":"2026-04-09T00:31:09.512Z","avatar_url":"https://github.com/luxuncang.png","language":"Python","readme":"# TypeFire\n\n [![CodeFactor](https://www.codefactor.io/repository/github/luxuncang/typefire/badge)](https://www.codefactor.io/repository/github/luxuncang/typefire)\n [![GitHub](https://img.shields.io/github/license/luxuncang/typefire)](https://github.com/luxuncang/typefire/blob/master/LICENSE)\n [![CodeQL](https://github.com/luxuncang/typefire/workflows/CodeQL/badge.svg)](https://github.com/luxuncang/typefire/blob/main/.github/workflows/codeql-analysis.yml)\n\n**通过装饰器零入侵性的，对 `fire-python` 的类型约束进行拓展，此外其还适用于任何函数对象进行基于注解的类型转换**\n\n## 安装\n\n```bash\npip install typefire\n```\n\n## 特性\n\n- 支持注解类型转换\n- 支持字符串类型注解\n- 支持 async/await\n- 零入侵性\n- 支持任意对象\n\n## Fire\n\n```python\nfrom pathlib import Path\nimport fire\n\n\ndef test_fire(path: Path):\n    print(type(path))\n    print(path)\n\n\nif __name__ == \"__main__\":\n    fire.Fire(test_fire)\n\n'''\npython test_fire.py \"/some_path_string\"\n\n\u003cclass 'str'\u003e\n/some_path_string\n'''\n```\n\nps: [fire #260](https://github.com/google/python-fire/issues/260#issue-620735435)\n\n## TypeFire\n\n```python\nfrom typefire import Switch, TypeFire, typefire, typeswitch\nimport fire\nimport pathlib\n\nTypeFire.add_switch(Switch(str, pathlib.Path, lambda p: pathlib.Path(p)))\n\n@typeswitch\ndef main(path: pathlib.Path, *args, **kwargs):\n    print(path, type(path))\n\nfire.Fire(main)\n\n'''\npython test_fire.py \"/some_path_string\"\n\n/some_path_string \u003cclass 'pathlib.WindowsPath'\u003e\n'''\n```\n\n```python\nfrom typefire import Switch, TypeFire, typefire, typeswitch\nimport fire\nimport pathlib\n\nTypeFire.add_switch(Switch(str, pathlib.Path, lambda p: pathlib.Path(p)))\n\n@typefire\ndef main(path: pathlib.Path, *args, **kwargs):\n    print(path, type(path))\n\nmain(\"/some_path_string\")\nmain(\"--path=/some_path_string\")\n```\n\n## typeswitch\n\n案例一：\n\n```python\nfrom typing import Union\n\ndef main(data: Union[bytes, Path, str]) -\u003e bytes:\n    if isinstance(data, bytes):\n        ...\n    elif isinstance(data, Path):\n        ...\n    elif isinstance(data, str):\n        ...\n```\n\n案例二：\n\n```python\nfrom typefire import Switch, typeswitch, TypeFire\nfrom pathlib import Path\n\nTypeFire.add_switch(Switch(str, bytes, lambda x: open(x, 'rb').read()))\nTypeFire.add_switch(Switch(Path, bytes, lambda x: open(x, 'rb').read()))\n\n@typeswitch()\ndef main(data: bytes):\n    print(type(data))\n\nmain(Path('test.py'))\nmain('test.py')\nmain(open('test.py', 'rb').read())\n\n'''\n\u003cclass 'bytes'\u003e\n\u003cclass 'bytes'\u003e\n\u003cclass 'bytes'\u003e\n'''\n```\n\n*显而易见 使用 `typeswitch` 显的更优雅，复用性更强*\n\nqs: [test](./test/test_typefire.py)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluxuncang%2Ftypefire","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluxuncang%2Ftypefire","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluxuncang%2Ftypefire/lists"}