Identify unwanted function calls in your code
Project description
Pyaphid
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
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyaphid-0.3.1.tar.gz.
File metadata
- Download URL: pyaphid-0.3.1.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cdc951d45294e71ca35d581a314f68e3164423ad3501247bd54f34c8716b2f08
|
|
| MD5 |
327671a42ddac704b0b1aa9ac12c84ec
|
|
| BLAKE2b-256 |
d4fae891fdd2633536e32011a531abf34646a8c9b223ee84dc9d4e4c95652080
|
File details
Details for the file pyaphid-0.3.1-py3-none-any.whl.
File metadata
- Download URL: pyaphid-0.3.1-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b58f2f465ed1d97db0c37a7f295ffe028d7f78b6be80e24f757270cec70ade94
|
|
| MD5 |
30ddb478cb30cfd5d86c2ac574082b7b
|
|
| BLAKE2b-256 |
561329ab60afd146ccc518b4b8ee43d37c1c3a328c30b7fec4e3be29af008814
|