{"id":20224982,"url":"https://github.com/adwaith-rajesh/py-module-info","last_synced_at":"2026-05-18T03:11:53.208Z","repository":{"id":62581816,"uuid":"369961549","full_name":"Adwaith-Rajesh/py-module-info","owner":"Adwaith-Rajesh","description":"A python package to get extra infoℹ about a Python 🐍 module, like the imports used, function called inside of other functions... etc","archived":false,"fork":false,"pushed_at":"2021-06-15T05:40:42.000Z","size":30,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-13T23:16:57.864Z","etag":null,"topics":["function-parser","imports-parser","python","python3"],"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/Adwaith-Rajesh.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-05-23T04:39:15.000Z","updated_at":"2021-06-25T12:21:02.000Z","dependencies_parsed_at":"2022-11-03T22:01:18.498Z","dependency_job_id":null,"html_url":"https://github.com/Adwaith-Rajesh/py-module-info","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Adwaith-Rajesh%2Fpy-module-info","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Adwaith-Rajesh%2Fpy-module-info/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Adwaith-Rajesh%2Fpy-module-info/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Adwaith-Rajesh%2Fpy-module-info/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Adwaith-Rajesh","download_url":"https://codeload.github.com/Adwaith-Rajesh/py-module-info/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241663488,"owners_count":19999325,"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":["function-parser","imports-parser","python","python3"],"created_at":"2024-11-14T07:10:15.378Z","updated_at":"2025-10-06T02:24:44.998Z","avatar_url":"https://github.com/Adwaith-Rajesh.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Py Module Info\n\n[![Testing](https://github.com/Adwaith-Rajesh/py-module-info/actions/workflows/tests.yml/badge.svg)](https://github.com/Adwaith-Rajesh/py-module-info/actions/workflows/tests.yml)\n[![Upload Python Package](https://github.com/Adwaith-Rajesh/py-module-info/actions/workflows/python-publish.yml/badge.svg)](https://github.com/Adwaith-Rajesh/py-module-info/actions/workflows/python-publish.yml)\n\nGet extra info about a python module, like imports, functions called inside other funcs etc.\n___\n\n## Installation\n```bash\npip install py-module-info\n```\n\n## Why use this?\nWell Idk, the `inspect` module in python requires you to import the module.\nThis package does not require you to import, but rather just looks at the python file like a normal text file and parses it. The problem with importing is that it may execute code that can harm your PC. So maybe ?\n\n\n## What does it do?\n\n### Get info about the imports used\n\n```python\n# test.py\n\nimport json\nimport pprint as p\nfrom typing import List as l\nfrom json import load, dump as d\nfrom py_module_info.main import ModuleInfo\n```\nTo get the imported names use\n\n```python\nfrom py_module_info import ModuleInfo\nm = ModuleInfo(\"test.py\")\nimports = m.get_imports()\nprint(imports.get_imported_names())\n\n# output\n['json', 'pprint', 'List', 'load', 'dump', 'ModuleInfo']\n\n# in order to get the alias names used\nprint(imports.get_imported_names(use_alias=True))\n# output\n['json', 'p', 'l', 'load', 'd', 'ModuleInfo']\n```\n\nTo get the literal import string in the module use\n\n```python\nfrom py_module_info import ModuleInfo\nm = ModuleInfo(\"test.py\")\nimports = m.get_imports()\nprint(imports.get_import_strings())\n\n# output\n['import json', 'import pprint', 'from typing import List',\n'from json import load', 'from json import dump', 'from py_module_info.main import ModuleInfo']\n\n# use alias names insted\nprint(imports.get_import_strings(use_alias=True))\n\n# output\n['import json', 'import pprint as p', 'from typing import List as l',\n'from json import load', 'from json import dump as d', 'from py_module_info.main import ModuleInfo']\n```\n#### Note\n * The imports will be split into individual imports:\n```python\n import test, json\n```\n* will become\n```python\nimport test\nimport json\n```\n\n### Get info about the function in the module.\n\n```python\n# test.py\n\nimport json\nfrom pprint import pprint\n\ndef foo():\n    pprint({\"Hello\": \"World\"})\n\n\n    with open(\"test.json\") as f:\n        print(json.load(f))\n```\n\nTo get info about the functions use\n```python\nfrom py_module_info import ModuleInfo\n\nm = ModuleInfo(\"test.py\")\nprint(m.get_funcs_info())\n\n# output\n{'foo': {'args': [], 'defaults': [], 'arg_count': 0, 'calls': ['json.load(f)', 'open(\"test.json\")', 'pprint({\"Hello\": \"World\"})', 'print(json.load(f))']}}\n\n```\nThe output includes the args passed in function, the defaults value for the the arguments, the argument count, and all the function calls that happened inside the function.\n\nThe function calls are all expanded and includes the entire call string.\n\nIn order to get just the function calls use\n\n```python\nfrom py_module_info import ModuleInfo\n\nm = ModuleInfo(\"test.py\")\nprint(m.get_funcs_info(only_func_name=True))\n\n# output\n{'foo': {'args': [], 'defaults': [], 'arg_count': 0, 'calls': ['load', 'open', 'pprint', 'print']}}\n\n```\n\n### Get info about the classes in a module\n```python\n# test.py\nclass Foo(A.Test):\n\n    def __init__(self, name):\n        self.name = name\n\n    def n():\n        pass\n\n\nclass Bar():\n\n    def a():\n        print('Hello')\n\n```\nTo get meta info about the classes in the module use\n```python\nfrom py_module_info import ModuleInfo\n\nm = ModuleInfo(\"test.py\")\nprint(m.get_classes_info())\n\n# output\n{'Foo': {'bases': ['A.Test'], 'methods': {'__init__': {'args': ['self', 'name'], 'defaults': [], 'arg_count': 2, 'calls': []}, 'n': {'args': [], 'defaults': [], 'arg_count': 0, \n'calls': []}}}, 'Bar': {'bases': [], 'methods': {'a': {'args': [], 'defaults': [], 'arg_count': 0, 'calls': [\"print('Hello')\"]}}}}\n```\n\nCurrently the output includes the information about the base classes and the info about different methods in the class.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadwaith-rajesh%2Fpy-module-info","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadwaith-rajesh%2Fpy-module-info","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadwaith-rajesh%2Fpy-module-info/lists"}