minimize python source code
Project description
pysource-minimize
If you build a linter, formatter or any other tool which has to analyse python source code you might end up searching bugs in pretty large input files.
pysource_minimize
is able to remove everything from the python source which is not related to the problem.
CLI
You can use pysource-minimize
from the command line like follow:
pysource-minimize --file bug.py --track "Assertion" -- python bug.py
This will run python bug.py
and try to find the string "Assertion" in the output.
The --file bug.py
gets minimized as long as "Assertion" is part of the output of the command.
[!WARNING] Be careful when you execute code which gets minimized. It might be that some combination of the code you minimize erases your hard drive or does other unintended things.
API
Example:
>>> from pysource_minimize import minimize
>>> source = """
... def f():
... print("bug"+"other string")
... return 1+1
... f()
... """
>>> print(minimize(source, lambda new_source: "bug" in new_source))
"""bug"""
Project details
Release history Release notifications | RSS feed
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
File details
Details for the file pysource_minimize-0.6.3.tar.gz
.
File metadata
- Download URL: pysource_minimize-0.6.3.tar.gz
- Upload date:
- Size: 11.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.11.0 Linux/6.1.0-20-amd64
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 142ce17507a8f24e9047a90f651926133d50293c36a3a89601df1a64c6520459 |
|
MD5 | 6db03492541b9e481db7d20e2479ccf4 |
|
BLAKE2b-256 | e0301369f9b3bce4841f80fbf67830a1c00b17da3b222fc8f3590c768245b541 |
File details
Details for the file pysource_minimize-0.6.3-py3-none-any.whl
.
File metadata
- Download URL: pysource_minimize-0.6.3-py3-none-any.whl
- Upload date:
- Size: 12.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.11.0 Linux/6.1.0-20-amd64
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bfe9ac0fe83770eece23c98107498f93794ad47ea133a9001c3b3b8b3b338140 |
|
MD5 | ba95e2e461adb12b6ed71f4716e005e7 |
|
BLAKE2b-256 | e5300a32b96f44c4b2b586e882fcaa5f85edfe005d2006404a507fb56ee453df |