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.1.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

pysource_minimize-0.6.1-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pysource_minimize-0.6.1.tar.gz
  • Upload date:
  • Size: 11.0 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.1.tar.gz
Algorithm Hash digest
SHA256 0805562eccb25e0a092d85e11e9e24b6b6aae41e6841074d435580fe5513ae0d
MD5 98bbac087588007e1109fab6355652c1
BLAKE2b-256 d9dbafa1a9ce05e3f87b2a06f54acecf2c9ee4537b621319b869e7b32fcfada4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pysource_minimize-0.6.1-py3-none-any.whl
  • Upload date:
  • Size: 12.5 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f5a8350b9d7b0ecebc112b746c315d940972d5f430a7580146b96d6f9052845b
MD5 adf86fadef5aa360c2655421a60faf12
BLAKE2b-256 337f4b646fc9d66100d41695ce0e3609aa2eff9272596126b9d737d53d93256b

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