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
Hashes for pysource_minimize-0.6.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4798a0a30087300548d893b23c1ca8b2e86f8f03abc9bacf56e32bb5430d0f39 |
|
MD5 | e9f6738439e254d8d3fffff16cc68b1c |
|
BLAKE2b-256 | 38ef85d75a7be015847dca5510cbcf6f6beccd93ff6c7b66ea8de02871a2ecc2 |