Skip to main content

Pyaphid

PyPI version GitHub license GitHub issues PyPI - Downloads Tests Codecov

Description

Pyaphid is a static analysis tool for detecting unwanted function calls in Python code.

Installation and usage

Installation: pip install pyaphid

Usage: python -m pyaphid <files and/or directories to analyze> or pyaphid <files and/or directories to analyze>

Configuration

Forbidden function calls can be configured via the pyproject.toml:

[tool.pyaphid]
forbidden = [
    "print", # forbid print(...)
    "pdb.run", # forbid pdb.run(...)
    "werkzeug.debug.*", # forbid werkzeug.debug.DebuggedApplication(...), werkzeug.debug.get_machine_id(...), ...
    "datetime.datetime.now" # forbid datetime.now()
]

With datetime.now for example you usually want to ignore one call to it for implementing a project-wide default function. You can use # pyaphid: ignore to ignore a line:

from dateutil.tz import tzlocal
from datetime import datetime

def get_now():
  # allowed
  return datetime.now(tzlocal()) # pyaphid: ignore

datetime.now() # forbidden

CLI Options

  • -n / --names: Look-up all func calls and print their identifier

As a pre-commit hook

- repo: https://github.com/jvllmr/pyaphid
  rev: v0.3.1
  hooks:
    - id: pyaphid

Limitations

# Pyaphid cannot work with star imports
from os.path import *
dirname(".") # undetected

# Pyaphid doesn't track assignments
my_print = print
my_print("Hello world") # undetected

Metadata

Release files for pyaphid 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyaphid 0.3.1
File Size Uploaded
pyaphid-0.3.1.tar.gz 7.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyaphid 0.3.1
File Interpreter ABI Platform
pyaphid-0.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 15.4 kB

Release files / pyaphid-0.3.1.tar.gz

Download URL pyaphid-0.3.1.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
cdc951d45294e71ca35d581a314f68e3164423ad3501247bd54f34c8716b2f08
BLAKE2b-256 checksum
How to use checksums
d4fae891fdd2633536e32011a531abf34646a8c9b223ee84dc9d4e4c95652080
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.2

Release files / pyaphid-0.3.1-py3-none-any.whl

Download URL pyaphid-0.3.1-py3-none-any.whl
Size 8.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b58f2f465ed1d97db0c37a7f295ffe028d7f78b6be80e24f757270cec70ade94
BLAKE2b-256 checksum
How to use checksums
561329ab60afd146ccc518b4b8ee43d37c1c3a328c30b7fec4e3be29af008814
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.2

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page