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

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pysource_minimize-0.8.0-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pysource_minimize-0.8.0.tar.gz
  • Upload date:
  • Size: 715.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pysource_minimize-0.8.0.tar.gz
Algorithm Hash digest
SHA256 e9a88c68717891dc7dc74beab769ef4c2e397599e1620b2046b89783fb500652
MD5 4ca1a8d3a5de5c8a6d7da7cae21de012
BLAKE2b-256 90d36786a52121987875b2e9d273399504e2bdb868e7b80b603ecb29c900846f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pysource_minimize-0.8.0.tar.gz:

Publisher: ci.yml on 15r10nk/pysource-minimize

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for pysource_minimize-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 edee433c24a2e8f81701aa7e01ba4c1e63f481f683dd3a561610762bc03ed6c3
MD5 a0f8fc3e0429a730befb6ecd99308615
BLAKE2b-256 4a7d4e9ed2a376bb7372d74fdec557f35f70c2bf5373f2c67e05535555d0a6d4

See more details on using hashes here.

Provenance

The following attestation bundles were made for pysource_minimize-0.8.0-py3-none-any.whl:

Publisher: ci.yml on 15r10nk/pysource-minimize

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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