pyufunc.pkg_dependents_func_usage#

pyufunc.pkg_dependents_func_usage(github_link, *, GITHUB_TOKEN=None, package_name=None, max_pages=20, max_dependents=None, max_files=300, max_file_size=300000, sleep_seconds=1.0)#

Collect dependent repositories and detect target package function usage.

Parameters:
  • github_link – URL of the target GitHub repository.

  • GITHUB_TOKEN – Optional GitHub token for authenticated requests. Can also be set via the GITHUB_TOKEN environment variable.

  • package_name – Optional import package name override. Use this when the repository or PyPI distribution name differs from the import name.

  • max_pages – Maximum number of GitHub dependents pages to scrape.

  • max_dependents – Optional maximum number of dependent repositories to scan.

  • max_files – Maximum number of Python files to inspect in each dependent repository.

  • max_file_size – Maximum Python file size, in bytes, to download and inspect.

  • sleep_seconds – Delay between GitHub dependents page requests.

Note

  • Source package: pyufunc.

  • Source repository: xyluo25/pyufunc

  • Source document: https://pyufunc.readthedocs.io/en/latest/

  • Source license: MIT License.

  • This function relies on GitHub’s web UI for dependents collection, which may be subject to change and rate limits. Use a token to increase the rate limit if you have many dependents. Unauthorized requests have very low rate limits (60 requests per hour); authenticated requests can have much higher limits (up to 5000 requests per hour).

  • The function usage detection is based on static analysis of Python files in the dependent repositories. It may not be 100% accurate but should give a good indication of which functions are used.

  • This function targets Python packages and Python dependent repositories.

  • GitHub does not provide a stable official REST API for dependents, so the dependents page is scraped.

  • Set environment variable GITHUB_TOKEN for better rate limits: Windows PowerShell: $env:GITHUB_TOKEN="ghp_xxx". Linux/macOS: export GITHUB_TOKEN="ghp_xxx".

  • For very popular packages, scanning all dependents can be slow.

Example

>>> github_url = ""
>>> github_token = ""  # Optional
>>> result = pkg_dependents_func_usage(github_url, GITHUB_TOKEN=github_token)
Returns:

A dictionary mapping each dependent repository in "owner/repo" format to function names detected from the target package. If a dependent repository cannot be processed, its value contains an error message.