2.10.0
ℹ️ Note that python-minifier depends on the python interpreter for parsing source code,
and will output source code compatible with the version of the interpreter it is run with.
This means that if you minify code written for Python 3.11 using python-minifier running with Python 3.12,
the minified code may only run with Python 3.12.
Added
-
Python 3.12 support, including:
- PEP 695 Type parameter syntax
- PEP 701 Improved f-strings
-
A new transform to remove the brackets when instantiating and raising built-in exceptions, which is enabled by default.
e.g.def a(): raise ValueError()
Will be minified to:
def a():raise ValueError
The raise statement automatically instantiates classes derived from Exception, so the brackets are not required.
-
A new constant folding transform, which is enabled by default.
This will evaluate simple expressions when minifying, e.g.SECONDS_IN_A_DAY = 60 * 60 * 24
Will be minified to:
SECONDS_IN_A_DAY=86400
Changed
-
Annotation removal is now more configurable, with separate options for:
- Removal of variable annotations (
--no-remove-variable-annotations
) - Removal of function return annotations (
--no-remove-return-annotations
) - Removal of function argument annotations (
--no-remove-argument-annotations
) - Removal of class attribute annotations (
--remove-class-attribute-annotations
)
The default behavior has changed, with class attribute annotations no longer removed by default.
These are increasingly being used at runtime, and removing them can cause issues. - Removal of variable annotations (
Fixed
- Fixed various subtle issues with renaming of names that overlap class scope.