python-minifier 2.11.0__tar.gz → 2.11.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {python_minifier-2.11.0/src/python_minifier.egg-info → python_minifier-2.11.2}/PKG-INFO +1 -1
- {python_minifier-2.11.0 → python_minifier-2.11.2}/setup.py +1 -1
- {python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier/rename/util.py +2 -1
- {python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier/transforms/remove_annotations.py +2 -2
- {python_minifier-2.11.0 → python_minifier-2.11.2/src/python_minifier.egg-info}/PKG-INFO +1 -1
- {python_minifier-2.11.0 → python_minifier-2.11.2}/test/test_rename_locals.py +79 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/LICENSE +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/README.md +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/setup.cfg +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier/__init__.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier/__init__.pyi +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier/__main__.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier/ast_compare.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier/ast_compat.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier/ast_printer.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier/expression_printer.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier/f_string.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier/ministring.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier/module_printer.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier/py.typed +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier/rename/__init__.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier/rename/bind_names.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier/rename/binding.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier/rename/mapper.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier/rename/name_generator.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier/rename/rename_literals.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier/rename/renamer.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier/rename/resolve_names.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier/token_printer.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier/transforms/__init__.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier/transforms/combine_imports.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier/transforms/constant_folding.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier/transforms/remove_annotations_options.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier/transforms/remove_annotations_options.pyi +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier/transforms/remove_asserts.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier/transforms/remove_debug.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier/transforms/remove_exception_brackets.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier/transforms/remove_explicit_return_none.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier/transforms/remove_literal_statements.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier/transforms/remove_object_base.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier/transforms/remove_pass.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier/transforms/remove_posargs.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier/transforms/suite_transformer.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier/util.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier.egg-info/SOURCES.txt +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier.egg-info/dependency_links.txt +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier.egg-info/entry_points.txt +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier.egg-info/top_level.txt +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier.egg-info/zip-safe +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/test/test_assignment_expressions.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/test/test_await_fstring.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/test/test_bind_names.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/test/test_bind_names_python2.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/test/test_bind_names_python312.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/test/test_bind_names_python313.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/test/test_bind_names_python33.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/test/test_combine_imports.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/test/test_comprehension_rename.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/test/test_decorator_expressions.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/test/test_dict_expansion.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/test/test_folding.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/test/test_fstring.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/test/test_generic_types.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/test/test_hoist_literals.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/test/test_import.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/test/test_is_ast_node.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/test/test_iterable_unpacking.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/test/test_match.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/test/test_match_rename.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/test/test_name_generator.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/test/test_nonlocal.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/test/test_posargs.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/test/test_preserve_shebang.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/test/test_remove_annotations.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/test/test_remove_assert.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/test/test_remove_debug.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/test/test_remove_exception_brackets.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/test/test_remove_explicit_return_none.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/test/test_remove_literal_statements.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/test/test_remove_object.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/test/test_remove_pass.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/test/test_rename_builtins.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/test/test_slice.py +0 -0
- {python_minifier-2.11.0 → python_minifier-2.11.2}/test/test_type_param_defaults.py +0 -0
|
@@ -85,7 +85,8 @@ def arg_rename_in_place(node):
|
|
|
85
85
|
return True
|
|
86
86
|
|
|
87
87
|
if isinstance(func.namespace, ast.ClassDef) and not isinstance(func, ast.Lambda):
|
|
88
|
-
|
|
88
|
+
all_args = (func.args.posonlyargs if hasattr(func.args, 'posonlyargs') else []) + func.args.args
|
|
89
|
+
if len(all_args) > 0 and node is all_args[0]:
|
|
89
90
|
if len(func.decorator_list) == 0:
|
|
90
91
|
# rename 'self'
|
|
91
92
|
return True
|
|
@@ -120,11 +120,11 @@ class RemoveAnnotations(SuiteTransformer):
|
|
|
120
120
|
if is_dataclass_field(node) or is_typing_sensitive(node):
|
|
121
121
|
return node
|
|
122
122
|
elif node.value:
|
|
123
|
-
return self.add_child(ast.Assign([node.target], node.value), parent=node.parent)
|
|
123
|
+
return self.add_child(ast.Assign([node.target], node.value), parent=node.parent, namespace=node.namespace)
|
|
124
124
|
else:
|
|
125
125
|
# Valueless annotations cause the interpreter to treat the variable as a local.
|
|
126
126
|
# I don't know of another way to do that without assigning to it, so
|
|
127
127
|
# keep it as an AnnAssign, but replace the annotation with '0'
|
|
128
128
|
|
|
129
|
-
node.annotation = self.add_child(ast.Num(0), parent=node.parent)
|
|
129
|
+
node.annotation = self.add_child(ast.Num(0), parent=node.parent, namespace=node.namespace)
|
|
130
130
|
return node
|
|
@@ -164,6 +164,85 @@ class TestClass():
|
|
|
164
164
|
actual_ast = rename_locals(source)
|
|
165
165
|
assert_code(expected_ast, actual_ast)
|
|
166
166
|
|
|
167
|
+
|
|
168
|
+
def test_rename_posargs_in_place():
|
|
169
|
+
if sys.version_info < (3, 8):
|
|
170
|
+
pytest.skip('No posonlyargs in python < 3.8')
|
|
171
|
+
|
|
172
|
+
source = '''
|
|
173
|
+
def test(arg, /, arg2): return arg, arg2
|
|
174
|
+
|
|
175
|
+
class TestClass():
|
|
176
|
+
def mymethod(self, arg, /, arg2): return arg, arg2
|
|
177
|
+
|
|
178
|
+
@classmethod
|
|
179
|
+
def mymethod(cls, arg, /, arg2): return arg, arg2
|
|
180
|
+
'''
|
|
181
|
+
expected = '''
|
|
182
|
+
def test(A,/,arg2):return A,arg2
|
|
183
|
+
class TestClass:
|
|
184
|
+
def mymethod(B,A,/,arg2):return A,arg2
|
|
185
|
+
@classmethod
|
|
186
|
+
def mymethod(B,A,/,arg2):return A,arg2
|
|
187
|
+
'''
|
|
188
|
+
|
|
189
|
+
expected_ast = ast.parse(expected)
|
|
190
|
+
actual_ast = rename_locals(source)
|
|
191
|
+
assert_code(expected_ast, actual_ast)
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
def test_rename_kwargonlyargs_in_place():
|
|
195
|
+
if sys.version_info < (3, 0):
|
|
196
|
+
pytest.skip('No kwonlyargs in python < 3.0')
|
|
197
|
+
|
|
198
|
+
source = '''
|
|
199
|
+
def test(arg, arg2, *, arg3): return arg, arg2, arg3
|
|
200
|
+
|
|
201
|
+
class TestClass():
|
|
202
|
+
def mymethod(self, arg, arg2, *, arg3): return arg, arg2, arg3
|
|
203
|
+
|
|
204
|
+
@classmethod
|
|
205
|
+
def mymethod(cls, arg, arg2, *, arg3): return arg, arg2, arg3
|
|
206
|
+
'''
|
|
207
|
+
expected = '''
|
|
208
|
+
def test(arg,arg2,*,arg3):return arg,arg2,arg3
|
|
209
|
+
class TestClass:
|
|
210
|
+
def mymethod(A,arg,arg2,*,arg3):return arg,arg2,arg3
|
|
211
|
+
@classmethod
|
|
212
|
+
def mymethod(A,arg,arg2,*,arg3):return arg,arg2,arg3
|
|
213
|
+
'''
|
|
214
|
+
|
|
215
|
+
expected_ast = ast.parse(expected)
|
|
216
|
+
actual_ast = rename_locals(source)
|
|
217
|
+
assert_code(expected_ast, actual_ast)
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
def test_rename_posargs_kwargonlyargs_in_place():
|
|
221
|
+
if sys.version_info < (3, 8):
|
|
222
|
+
pytest.skip('No posonlyargs in python < 3.8')
|
|
223
|
+
|
|
224
|
+
source = '''
|
|
225
|
+
def test(arg, /, arg2, *, arg3): return arg, arg2, arg3
|
|
226
|
+
|
|
227
|
+
class TestClass():
|
|
228
|
+
def mymethod(self, arg, /, arg2, *, arg3): return arg, arg2, arg3
|
|
229
|
+
|
|
230
|
+
@classmethod
|
|
231
|
+
def mymethod(cls, arg, /, arg2, *, arg3): return arg, arg2, arg3
|
|
232
|
+
'''
|
|
233
|
+
expected = '''
|
|
234
|
+
def test(A,/,arg2,*,arg3):return A,arg2,arg3
|
|
235
|
+
class TestClass:
|
|
236
|
+
def mymethod(B,A,/,arg2,*,arg3):return A,arg2,arg3
|
|
237
|
+
@classmethod
|
|
238
|
+
def mymethod(B,A,/,arg2,*,arg3):return A,arg2,arg3
|
|
239
|
+
'''
|
|
240
|
+
|
|
241
|
+
expected_ast = ast.parse(expected)
|
|
242
|
+
actual_ast = rename_locals(source)
|
|
243
|
+
assert_code(expected_ast, actual_ast)
|
|
244
|
+
|
|
245
|
+
|
|
167
246
|
def test_no_rename_long_arg():
|
|
168
247
|
source = '''
|
|
169
248
|
def f(this_is_my_long_argument_name):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier/rename/name_generator.py
RENAMED
|
File without changes
|
{python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier/rename/rename_literals.py
RENAMED
|
File without changes
|
|
File without changes
|
{python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier/rename/resolve_names.py
RENAMED
|
File without changes
|
|
File without changes
|
{python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier/transforms/__init__.py
RENAMED
|
File without changes
|
{python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier/transforms/combine_imports.py
RENAMED
|
File without changes
|
{python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier/transforms/constant_folding.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier/transforms/remove_asserts.py
RENAMED
|
File without changes
|
{python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier/transforms/remove_debug.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier/transforms/remove_pass.py
RENAMED
|
File without changes
|
{python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier/transforms/remove_posargs.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier.egg-info/entry_points.txt
RENAMED
|
File without changes
|
{python_minifier-2.11.0 → python_minifier-2.11.2}/src/python_minifier.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|