{"id":37608751,"url":"https://github.com/micheleantonazzi/python-stub-runtime-generator","last_synced_at":"2026-01-16T10:15:23.425Z","repository":{"id":57471988,"uuid":"357257146","full_name":"micheleantonazzi/python-stub-runtime-generator","owner":"micheleantonazzi","description":null,"archived":false,"fork":false,"pushed_at":"2024-12-02T15:01:03.000Z","size":43,"stargazers_count":11,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-26T21:30:47.235Z","etag":null,"topics":["python-autocomplete","python3","runtime","stubs"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/micheleantonazzi.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":"2021-04-12T16:05:08.000Z","updated_at":"2025-08-01T22:38:21.000Z","dependencies_parsed_at":"2022-08-30T13:52:11.050Z","dependency_job_id":null,"html_url":"https://github.com/micheleantonazzi/python-stub-runtime-generator","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/micheleantonazzi/python-stub-runtime-generator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/micheleantonazzi%2Fpython-stub-runtime-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/micheleantonazzi%2Fpython-stub-runtime-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/micheleantonazzi%2Fpython-stub-runtime-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/micheleantonazzi%2Fpython-stub-runtime-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/micheleantonazzi","download_url":"https://codeload.github.com/micheleantonazzi/python-stub-runtime-generator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/micheleantonazzi%2Fpython-stub-runtime-generator/sbom","scorecard":{"id":641986,"data":{"date":"2025-08-11","repo":{"name":"github.com/micheleantonazzi/python-stub-runtime-generator","commit":"f04d1184d087debd7f190a3359f7b47086643831"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.4,"checks":[{"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":"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":"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":"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":"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":"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/build-and-publish.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/micheleantonazzi/python-stub-runtime-generator/build-and-publish.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build-and-publish.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/micheleantonazzi/python-stub-runtime-generator/build-and-publish.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build-and-publish.yml:33: update your workflow using https://app.stepsecurity.io/secureworkflow/micheleantonazzi/python-stub-runtime-generator/build-and-publish.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build-and-publish.yml:34: update your workflow using https://app.stepsecurity.io/secureworkflow/micheleantonazzi/python-stub-runtime-generator/build-and-publish.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build-and-publish.yml:53: update your workflow using https://app.stepsecurity.io/secureworkflow/micheleantonazzi/python-stub-runtime-generator/build-and-publish.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/build-and-publish.yml:67: update your workflow using https://app.stepsecurity.io/secureworkflow/micheleantonazzi/python-stub-runtime-generator/build-and-publish.yml/main?enable=pin","Warn: pipCommand not pinned by hash: .github/workflows/build-and-publish.yml:20","Warn: pipCommand not pinned by hash: .github/workflows/build-and-publish.yml:21","Warn: pipCommand not pinned by hash: .github/workflows/build-and-publish.yml:37","Warn: pipCommand not pinned by hash: .github/workflows/build-and-publish.yml:38","Warn: pipCommand not pinned by hash: .github/workflows/build-and-publish.yml:58","Warn: pipCommand not pinned by hash: .github/workflows/build-and-publish.yml:59","Info:   0 out of   5 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party GitHubAction dependencies pinned","Info:   0 out of   6 pipCommand 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":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/build-and-publish.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":0,"reason":"no SAST tool detected","details":["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":"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":"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":"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":"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":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: 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":"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-21T11:00:10.689Z","repository_id":57471988,"created_at":"2025-08-21T11:00:10.689Z","updated_at":"2025-08-21T11:00:10.689Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28478049,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T06:30:42.265Z","status":"ssl_error","status_checked_at":"2026-01-16T06:30:16.248Z","response_time":107,"last_error":"SSL_read: 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":["python-autocomplete","python3","runtime","stubs"],"created_at":"2026-01-16T10:15:23.331Z","updated_at":"2026-01-16T10:15:23.412Z","avatar_url":"https://github.com/micheleantonazzi.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Python stub runtime generator\n![](https://github.com/micheleantonazzi/python-stub-runtime-generator/workflows/Build/badge.svg?branch=main)\n[![pypi package](https://img.shields.io/pypi/v/stub-generator.svg)](https://pypi.org/project/stub-generator/)\n![PyPI Downloads](https://static.pepy.tech/badge/stub-generator)\n[![](https://sonarcloud.io/api/project_badges/measure?project=micheleantonazzi_python-stub-runtime-generator\u0026metric=coverage)](https://sonarcloud.io/dashboard/index/micheleantonazzi_python-stub-runtime-generator)\n\n\n\n[![](https://sonarcloud.io/api/project_badges/measure?project=micheleantonazzi_python-stub-runtime-generator\u0026metric=sqale_rating)](https://sonarcloud.io/dashboard/index/micheleantonazzi_python-stub-runtime-generator)\n[![](https://sonarcloud.io/api/project_badges/measure?project=micheleantonazzi_python-stub-runtime-generator\u0026metric=reliability_rating)](https://sonarcloud.io/dashboard/index/micheleantonazzi_python-stub-runtime-generator)\n[![](https://sonarcloud.io/api/project_badges/measure?project=micheleantonazzi_python-stub-runtime-generator\u0026metric=security_rating)](https://sonarcloud.io/dashboard/index/micheleantonazzi_python-stub-runtime-generator)\n[![](https://sonarcloud.io/api/project_badges/measure?project=micheleantonazzi_python-stub-runtime-generator\u0026metric=vulnerabilities)](https://sonarcloud.io/dashboard/index/micheleantonazzi_python-stub-runtime-generator)\n\nThis utility package generates Python stub files at run time to enhance the autocomplete capabilities of your favorite Python IDE.\n\nPython is a dynamically typed language: the Python interpreter does type checking only when the code is run. This means that the type of a variable is allowed to change over its lifetime. \nHowever, Python 3.x syntax introduces *type hints*, which makes it possible to statically checking Python code. \nDespite this mechanism, Python doesn't work like other statically typed languages. \nIn fact, *type hints* doesn't cause the type enforcing, but it provides only suggestions to prevent common mistakes.\nThe most famous Python IDEs help programmers providing an autocomplete system, which suggests the type of variables, the class methods, the function parameters and so on.\nThis makes coding faster and easier. It analyses statically the Python files and, with the help of *type hints*, gives to the coder a lot of useful information to improve its activity.\nHowever, Python implements the *metaprogramming* paradigm.\nThe term *metaprogramming* refers to the potential for a program to have knowledge of or manipulate itself.\nIn other words, Python allows generating code at run time using the metaclasses.\nThis represents an obstacle to autocomplete systems: they cannot suggest what is defined during the code execution.\nTo solve this issue, it is possible to use a *stub file*,\nwhich defines the code skeleton and the public interface of a module.\nBy parsing this file, an autocomplete tool can provide hints and suggestions to the programmer,\nin order to make the coding activity faster.\nThis utility automatically creates *stub files* at run time, loading the Python code and analyzing it dynamically.\n\n## Known issues\n\n* **Recursion import error:** the generate_stub() method fails if the file passed to constructor is the same in which the StubGenerator instance is declared. To solve it, just create another file to use StubGenerator.\n\n## How it works\n\nThe main object is called StubGenerator. It takes a Python file path and generates the corresponding stub file in the same directory. \n\n**NB:** annotate as much as possible your Python file to improve the stub file quality. Use *doc-strings* and *type hints*.\n\nTo produce a stub file, run this code \n\n```python\nStubGenerator(file_path='*.py', members_from_other_modules=['member_defined_in_other_module',...]).generate_stubs().write_to_file()\n```\n\n```StubGenerator(file_path='*.py', members_from_other_modules=['member_defined in other_module',...]).generate_stubs().write_to_file()```. The StubGenerator object produces the stub file of the given file and save it in the same path. By default, only members defined in that file are considered, the others are ignored. It is possible to produce the stub for a member defined in another file, just use the second parameter of the constructor.\n\nFor example, if you have a Python file like this:\n\n```python\nimport sys\nimport numpy as np\nimport typing as tp\nfrom typing import Any\n\nclass A:\n    pass\n\ndef f_meta(self, c: tp.Callable, i: int, a: A = A(), s: str = 'Hi') -\u003e int:\n    \"\"\"\n    docstring\n    \"\"\"\n    return 1\n\n\nclass Meta(type):\n    def __new__(cls, classname, supers, classdict):\n        classdict['f_meta'] = f_meta\n        return type.__new__(cls, classname, supers, classdict)\n\n\nclass TestClass(metaclass=Meta):\n    def __init__(self, a: np.ndarray, b: Any):\n        self._a = a\n\n    def f(self, b: int) -\u003e np.ndarray:\n        \"\"\"\n        docstring\n        :param b:\n        :return:\n        \"\"\"\n        return np.array([b])\n. its name \n\ns = 'string'\n\nlam = lambda x: x\n```\n\nThis module produces the the following stub file:\n\n```python\nimport sys\nimport numpy\nimport typing\n\nclass A(object, metaclass=type):\n\t...\n\ndef f_meta(self, c: typing.Callable, i: int, a: A, s: str = 'Hi') -\u003e int:\n\t\"\"\"\n\tdocstring\n\t\"\"\"\n\t...\n\nclass Meta(type, metaclass=type):\n\t...\n\nclass TestClass(object, metaclass=Meta):\n\tdef __init__(self, a: numpy.ndarray, b: typing.Any):\n\t\t...\n\tdef f(self, b: int) -\u003e numpy.ndarray:\n\t\t\"\"\"\n\t\tdocstring\n\t\t:param b:\n\t\t:return:\n\t\t\"\"\"\n\t\t...\n\tdef f_meta(self, c: typing.Callable, i: int, a: A, s: str = 'Hi') -\u003e int:\n\t\t\"\"\"\n\t\tdocstring\n\t\t\"\"\"\n\t\t...\n\t...\n\ns: str\n\ndef lam(x):\n\t...\n```\n\n## Tips\n\nTo use this module successfully, you need to change your code style a little, following these tips:\n\n* *StubGenerator* considers only the types that are defined in the input file. For example, the line ```MyException = Exception``` is ignored, because the type *MyExcpetion* is another way to call *Exception* type, which is defined in another file. This issues can be easily overcome passing 'MyException' to StubGenerator constructor:\n\n  ```python\n  StubGenerator(file_path='*.py', members_from_other_modules=['MyException']).generate_stubs().write_to_file()\n  ```\n\n  or defining a new type:\n\n  ```python\n  class MyException(Exception):\n  \tpass\n  ```\n\n* the default parameters of a function are ignored if they are objects other than strings, integers, floats, etc. For example, for a function like this ```def f(s = 'Hi', a = A()): pass``` the output will be ```def f(s = 'Hi', a): pass```. This is an error for the Python syntax, just invert the parameter.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicheleantonazzi%2Fpython-stub-runtime-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmicheleantonazzi%2Fpython-stub-runtime-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicheleantonazzi%2Fpython-stub-runtime-generator/lists"}