Skip to content

Releases: dflook/python-minifier

2.9.0

01 May 12:18
fd3dee4
Compare
Choose a tag to compare

Added

  • A new transform to remove return statements that are not required, which is enabled by default.
    e.g.
def important(a):
   if a > 3:
       return a
   if a < 2:
       return None
   a.adjust(1)
   return None

Will be minified to:

def important(a):
    if a > 3:
        return a
    if a < 2:
        return
    a.adjust(1)
  • The f-string debug specifier will now be used where possible, e.g. f'my_var={my_var!r}' will be minified to f'{my_var=}'.
    The debug specifier should now be preserved where it is used in the input source.

  • Many small improvements to minification to be more precise about where whitespace or parentheses required

    • Thanks luk3yx for improving whitespace in relative import statements.
    • A generator as the sole argument to a function call is no longer wrapped in parentheses
    • float literals can use a more compact scientific notation
    • Many more subtle improvements

2.8.1

15 Mar 23:54
6698d95
Compare
Choose a tag to compare

Fixed

  • A bug shortening names in the iterable of a comprehension when the original name was also used as a target in the comprehension
    e.g. def f(x): return [x for x in x] would be incorrectly minified to def f(x):return[A for A in A], instead of def f(x):return[A for A in x].

2.8.0

27 Dec 12:12
2acc4e0
Compare
Choose a tag to compare

Added

  • New transforms that together work similarly to Python's -O option
    • Remove asserts, which removes assert statements and is disabled by default
    • Remove debug, which removes any if block that tests __debug__ is True and is disabled by default

Changed

  • When minifiying a directory, files ending with '.pyw' will now be minified.

2.7.0

27 Oct 17:08
daea1d4
Compare
Choose a tag to compare

Added

  • Python 3.11 support, including exception groups syntax

Changed

  • Improved detection of dataclasses when using the remove annotations transform, which suppresses removal of annotations for those classes

Fixed

  • Renamed nonlocal names could be incorrect if the name isn't local in the immediate parent function scope.
    (or it was bound in the immediate parent, but after the definition of the nested scope)

2.6.0

10 Apr 17:44
5fd495c
Compare
Choose a tag to compare

Added

  • A new option to preserve the shebang line from the source file, which is enabled by default
  • More flexible file processing options for the pyminify command:
    • A new --output argument for writing the minified output to a file without having to use shell redirection
    • A new --in-place option which overwrites the specified path with the minified output
    • path arguments may be directories, which minifies all *.py files below that directory
    • Multiple path arguments may be specified, which will all be minified
  • Type information is included in the package to enable type checking of the public functions

Fixed

  • No longer assumes files read from stdin are utf-8.

2.5.0

06 Oct 14:19
0008fdf
Compare
Choose a tag to compare

Added

  • Support for Python 3.10, including pattern matching syntax

Changed

  • Makes better decisions about when renaming is space efficient

2.4.2

28 Jun 19:37
1b1b958
Compare
Choose a tag to compare

Fixed

  • Rare Exceptions when encountering empty f-string str parts
  • Missing required parentheses in return statements for iterable unpacking in python <3.8
  • Missing parentheses in some complex dict expansions

Removed

  • Python 2.6 support

2.4.1

17 Oct 10:15
6cc0fbd
Compare
Choose a tag to compare

Changed

  • When the remove annotation transformation is enabled, annotations are preserved on detected usage of TypedDict or NamedTuple

2.4.0

15 Oct 08:14
Compare
Choose a tag to compare

Added

  • Support for Python 3.9, including:
    • PEP 614 - Relaxing Grammar Restrictions On Decorators

2.3.2

11 Oct 16:59
f10d58a
Compare
Choose a tag to compare

Fixed

  • await keyword can now be used in f-string expression parts