Skip to main content

minimize python source code

Project description

pypi version Python Versions PyPI - Downloads GitHub Sponsors

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.

example

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pysource_minimize-0.6.0.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

pysource_minimize-0.6.0-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file pysource_minimize-0.6.0.tar.gz.

File metadata

  • Download URL: pysource_minimize-0.6.0.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.0 Linux/6.1.0-13-amd64

File hashes

Hashes for pysource_minimize-0.6.0.tar.gz
Algorithm Hash digest
SHA256 9fc1a63020c69e6b5a6d7bc5f8fc968e930a4f62d189b6acd7ea4a83fcef5125
MD5 929f4e1e0c9dc1a783bb7fbec1f74fc0
BLAKE2b-256 a1348fa76c43cd3e216fc772357ee9c2cea301af7c4ec828019730abe5300a00

See more details on using hashes here.

File details

Details for the file pysource_minimize-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: pysource_minimize-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 12.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.0 Linux/6.1.0-13-amd64

File hashes

Hashes for pysource_minimize-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c4596508c3092ed264e7c0d7f1ab0571c9e6e359b50b5d82009de8626a9f33f9
MD5 ba7dc49faef7624af9ef79ca813ae823
BLAKE2b-256 54c35c3ba8571d0a1d7d305efe37e99d65fcb0d899226ead64b6548d55a8c890

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page