Command Usage

The pyminify command is installed with this package. It can be used to minify python files, and outputs the result to stdout.

usage: pyminify [-h] [--output OUTPUT | --in-place] [--no-combine-imports]
                [--no-remove-pass] [--remove-literal-statements]
                [--no-remove-annotations] [--no-hoist-literals]
                [--no-rename-locals] [--preserve-locals LOCAL_NAMES]
                [--rename-globals] [--preserve-globals GLOBAL_NAMES]
                [--no-remove-object-base] [--no-convert-posargs-to-args]
                [--no-preserve-shebang] [--version]
                path [path ...]

Minify Python source code

positional arguments:
  path                  The source file or directory to minify. Use "-" to
                        read from stdin. Directories are recursively searched
                        for ".py" files to minify. May be used multiple times

  -h, --help            show this help message and exit
  --output OUTPUT, -o OUTPUT
                        Path to write minified output. Can only be used when
                        the source is a single module
  --in-place, -i        Overwrite existing files. Required when there is more
                        than one source module
  --version, -v         show program's version number and exit

minification options:
  Options that affect how the source is minified

  --no-combine-imports  Disable combining adjacent import statements
  --no-remove-pass      Disable removing Pass statements
                        Enable removing statements that are just a literal
                        (including docstrings)
                        Disable removing function and variable annotations
  --no-hoist-literals   Disable replacing string and bytes literals with
  --no-rename-locals    Disable shortening of local names
  --preserve-locals LOCAL_NAMES
                        Comma separated list of local names that will not be
  --rename-globals      Enable shortening of global names
  --preserve-globals GLOBAL_NAMES
                        Comma separated list of global names that will not be
                        Disable removing object from base class list
                        Disable converting positional only arguments to normal
                        Preserve any shebang line from the source

  # Minifying stdin to stdout
  pyminify -

  # Minifying a file to stdout

  # Minifying a file and writing to a different file
  pyminify --output

  # Minifying a file in place
  pyminify --in-place

  # Minifying all *.py files in a directory
  pyminify src/ --in-place

  # Minifying multiple paths in place
  pyminify src/ --in-place