python-minifier 3.1.0__py2-none-any.whl → 3.1.1__py2-none-any.whl

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.
@@ -63,7 +63,7 @@ def compare_ast(l_ast, r_ast):
63
63
 
64
64
  if field == 'kind' and isinstance(l_ast, ast.Constant):
65
65
  continue
66
-
66
+
67
67
  if field == 'str' and hasattr(ast, 'Interpolation') and isinstance(l_ast, ast.Interpolation):
68
68
  continue
69
69
 
@@ -77,4 +77,4 @@ for _node_type in [
77
77
  'withitem',
78
78
  ]:
79
79
  if _node_type not in globals():
80
- globals()[_node_type] = type(_node_type, (AST,), {})
80
+ globals()[_node_type] = type(_node_type, (AST,), {})
@@ -301,8 +301,8 @@ class ExpressionPrinter(object):
301
301
 
302
302
  if value_precedence != 0 and (
303
303
  (op_precedence > value_precedence)
304
- or op_precedence == value_precedence
305
- and self._is_left_associative(node.op)
304
+ or (op_precedence == value_precedence
305
+ and self._is_left_associative(node.op))
306
306
  ):
307
307
  self.printer.delimiter('(')
308
308
  self._expression(v)
@@ -596,7 +596,7 @@ class ModulePrinter(ExpressionPrinter):
596
596
  self.printer.keyword('case')
597
597
 
598
598
  if isinstance(node.pattern, ast.MatchSequence):
599
- self.visit_MatchSequence(node.pattern, open=True)
599
+ self.visit_MatchSequence(node.pattern, omit_brackets=True)
600
600
  else:
601
601
  self.pattern(node.pattern)
602
602
 
@@ -626,10 +626,10 @@ class ModulePrinter(ExpressionPrinter):
626
626
  else:
627
627
  self.printer.identifier(node.name)
628
628
 
629
- def visit_MatchSequence(self, node, open=False):
629
+ def visit_MatchSequence(self, node, omit_brackets=False):
630
630
  assert isinstance(node, ast.MatchSequence)
631
631
 
632
- if len(node.patterns) < 2 or not open:
632
+ if len(node.patterns) < 2 or not omit_brackets:
633
633
  self.printer.delimiter('[')
634
634
 
635
635
  delimiter = Delimiter(self.printer)
@@ -637,7 +637,7 @@ class ModulePrinter(ExpressionPrinter):
637
637
  delimiter.new_item()
638
638
  self.pattern(pattern)
639
639
 
640
- if len(node.patterns) < 2 or not open:
640
+ if len(node.patterns) < 2 or not omit_brackets:
641
641
  self.printer.delimiter(']')
642
642
 
643
643
  def visit_MatchMapping(self, node):
@@ -35,7 +35,7 @@ def sorted_bindings(module):
35
35
  """
36
36
 
37
37
  def comp(tup):
38
- namespace, binding = tup
38
+ _namespace, binding = tup
39
39
  return binding.new_mention_count()
40
40
 
41
41
  return sorted(all_bindings(module), key=comp, reverse=True)
@@ -103,7 +103,7 @@ class TokenPrinter(object):
103
103
  def __str__(self):
104
104
  """Return the output code."""
105
105
  return self._code
106
-
106
+
107
107
  def __unicode__(self):
108
108
  """Return the output code as unicode (for Python 2.7 compatibility)."""
109
109
  return self._code
@@ -27,18 +27,38 @@ class RemoveDebug(SuiteTransformer):
27
27
  if not isinstance(node, ast.If):
28
28
  return False
29
29
 
30
- if isinstance(node.test, ast.Name) and node.test.id == '__debug__':
31
- return True
30
+ def is_simple_debug_check():
31
+ # Simple case: if __debug__:
32
+ if isinstance(node.test, ast.Name) and node.test.id == '__debug__':
33
+ return True
34
+ return False
32
35
 
33
- if isinstance(node.test, ast.Compare) and len(node.test.ops) == 1 and isinstance(node.test.ops[0], ast.Is) and self.constant_value(node.test.comparators[0]) is True:
34
- return True
36
+ def is_truthy_debug_comparison():
37
+ # Comparison case: if __debug__ is True / False / etc.
38
+ if not isinstance(node.test, ast.Compare):
39
+ return False
35
40
 
36
- if isinstance(node.test, ast.Compare) and len(node.test.ops) == 1 and isinstance(node.test.ops[0], ast.IsNot) and self.constant_value(node.test.comparators[0]) is False:
37
- return True
41
+ if not isinstance(node.test.left, ast.Name):
42
+ return False
38
43
 
39
- if isinstance(node.test, ast.Compare) and len(node.test.ops) == 1 and isinstance(node.test.ops[0], ast.Eq) and self.constant_value(node.test.comparators[0]) is True:
40
- return True
44
+ if node.test.left.id != '__debug__':
45
+ return False
41
46
 
47
+ if len(node.test.ops) == 1:
48
+ op = node.test.ops[0]
49
+ comparator_value = self.constant_value(node.test.comparators[0])
50
+
51
+ if isinstance(op, ast.Is) and comparator_value is True:
52
+ return True
53
+ if isinstance(op, ast.IsNot) and comparator_value is False:
54
+ return True
55
+ if isinstance(op, ast.Eq) and comparator_value is True:
56
+ return True
57
+
58
+ return False
59
+
60
+ if is_simple_debug_check() or is_truthy_debug_comparison():
61
+ return True
42
62
  return False
43
63
 
44
64
  def suite(self, node_list, parent):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-minifier
3
- Version: 3.1.0
3
+ Version: 3.1.1
4
4
  Summary: Transform Python source code into it's most compact representation
5
5
  Home-page: https://github.com/dflook/python-minifier
6
6
  Author: Daniel Flook
@@ -148,7 +148,7 @@ and outputs source code compatible with the version of the interpreter it is run
148
148
  This means that if you minify code written for Python 3.11 using python-minifier running with Python 3.12,
149
149
  the minified code may only run with Python 3.12.
150
150
 
151
- python-minifier runs with and can minify code written for Python 2.7 and Python 3.3 to 3.13.
151
+ python-minifier runs with and can minify code written for Python 2.7 and Python 3.3 to 3.14.
152
152
 
153
153
  ## Usage
154
154
 
@@ -1,16 +1,16 @@
1
1
  python_minifier/__init__.py,sha256=Q95ufDbd7hadjVtJZYclsJqX9S4NsKZSpqCui0Fw7oI,9542
2
2
  python_minifier/__init__.pyi,sha256=-xLoKXbQsV7ko_YzyXL9WkI2vmGc6yn4AW5biK_GJXE,1233
3
3
  python_minifier/__main__.py,sha256=r7_Vh9n-aoc4jd5CERKO3KqJeqXHeWoycDRlvV7xTFM,14053
4
- python_minifier/ast_compare.py,sha256=fYtIIo_d16I4GgjPIjXSWcQkauNYQvF7qiQV-cilSg8,3389
5
- python_minifier/ast_compat.py,sha256=8QcPcujdHtDT7691d48_1L3_CzHgtvpWDAtWMr2Z9Eg,2249
4
+ python_minifier/ast_compare.py,sha256=KQyS9TGA1SoCs8uu4iks1IINFb_pEj7x38Q4oiERWnI,3381
5
+ python_minifier/ast_compat.py,sha256=DFJ7WmrEfYXfaby8EWt1aRlcqVPPoXD4Fh9Hnb9dLCU,2250
6
6
  python_minifier/ast_printer.py,sha256=TlkyKl9_9ScWeop3W1TwXZ46MJWINfkJ7NvmULpwt4A,3254
7
- python_minifier/expression_printer.py,sha256=EEtnpdipgf0zjkbacloAAjyWBw0tvFz1tloLL6ZnNig,22670
7
+ python_minifier/expression_printer.py,sha256=rBegwnqsjT_buJwSqK_piLwnfCwPyshzUUYgShoZPB4,22676
8
8
  python_minifier/f_string.py,sha256=eXYXaxEMSB3iHY_M_RXYpeloJV-7TYnhWIGge0KYCk8,18314
9
9
  python_minifier/ministring.py,sha256=R0xaAZqMlLu1Jm0aBVSI0n8KZiZV7PTs4RE4UbCmTy8,4359
10
- python_minifier/module_printer.py,sha256=CZFZ3WDBgH57_Q2pmC0ySFdRcvQR_7uVQeXKfvT1BN0,25566
10
+ python_minifier/module_printer.py,sha256=zVdsUXm2GkdbIbNUyuavaOWRhn7FP93UqRibhuiokfQ,25602
11
11
  python_minifier/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
12
  python_minifier/t_string.py,sha256=z3KzWaSDqvy701SY3dm8VSkiJuiUfopSWGNIm-nDpAo,13261
13
- python_minifier/token_printer.py,sha256=t4MmgulfQROWGd4n8HNyIDqo8cIxJg9LBxnFIbJwIr4,9987
13
+ python_minifier/token_printer.py,sha256=MoVyC_ufvTXtI5bAIq6XdWDrkUTF6oYBmto3ILfq_KU,9983
14
14
  python_minifier/util.py,sha256=60iT3XkKlPlZhXQ1NuLB27Wv3ihl-gBC_WjOjEiFn-Q,1184
15
15
  python_minifier/ast_annotation/__init__.py,sha256=BJ4gyS-_bytIZf0SP8JJG6FECWf8MUaUi3vOAfD60qQ,2259
16
16
  python_minifier/rename/__init__.py,sha256=8DLEFgliakf_5T_m-l1Nd35QxKpM4h7RJyFVpjsxjWA,375
@@ -19,7 +19,7 @@ python_minifier/rename/binding.py,sha256=WPospKLbZN7nnzDayJ55HMxuS-E5zvOE78RJkKi
19
19
  python_minifier/rename/mapper.py,sha256=h3dgg3JgUGQhW7oGwBX1syUgmt5AuaF_OP8dW5ImS5o,6482
20
20
  python_minifier/rename/name_generator.py,sha256=70Klx2DteYRpBT8dr6jYDB31ARfinS42e08kKlWAzLg,1269
21
21
  python_minifier/rename/rename_literals.py,sha256=qKJYCK8X7jEi7IW2PFiOqIjj0pn-1Cz1WaiBEGkUmIw,7488
22
- python_minifier/rename/renamer.py,sha256=B9kNiTkWDw7i7tKQASrCZ4fXsjKf9AspFSUfuxQWZFs,6600
22
+ python_minifier/rename/renamer.py,sha256=UQWrWrmntT0laNjTxEcH-cK4nZXAzi6LtJCI_STYZbo,6601
23
23
  python_minifier/rename/resolve_names.py,sha256=VbePyUUqggvvcF3fAC6XMv6b3Kmb_cmlO9G7vf5Ti-c,4320
24
24
  python_minifier/rename/util.py,sha256=ItJykxM_QRjIePMcKYo-LngmP5hLQZK-bOZIefg1cKA,5469
25
25
  python_minifier/transforms/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -29,7 +29,7 @@ python_minifier/transforms/remove_annotations.py,sha256=qUCdl42yvq1g7B43d88EOz6J
29
29
  python_minifier/transforms/remove_annotations_options.py,sha256=kzg-gEPwhrCZxsuzdpEWjqnhsyF89hnIPv1t-IRty64,1889
30
30
  python_minifier/transforms/remove_annotations_options.pyi,sha256=jZp8hUQ-BfqU1qA_nsPiluMM-1jznSX3pzbmysvKv-c,518
31
31
  python_minifier/transforms/remove_asserts.py,sha256=obccCHRSK6j5z0Slb4vVvK5kPVKobZNQo1HjJeX1N0g,738
32
- python_minifier/transforms/remove_debug.py,sha256=vuWJPFBMPYZEcSU8oRZ8w41tWl16B0mxpVvxEu4PiwY,1869
32
+ python_minifier/transforms/remove_debug.py,sha256=r5owpGW-T9yh7m5OmdIwCMiYF-1LPBQOQ2FYWRuhNWQ,2334
33
33
  python_minifier/transforms/remove_exception_brackets.py,sha256=hOUxrfsl9-u8M1kLbqJ6wR8PFtKWSmmyKdTDkh-XsDA,4214
34
34
  python_minifier/transforms/remove_explicit_return_none.py,sha256=drXry0dejtMWLZJCkGh4d7fc89MqiUVCXgaonn6Como,1301
35
35
  python_minifier/transforms/remove_literal_statements.py,sha256=mrxgSNtI2J1Nv9DaSiXMlrqvEj1lDAAY5_niWh8PmZg,1631
@@ -37,10 +37,10 @@ python_minifier/transforms/remove_object_base.py,sha256=j4se6OXyZK1lr_ABmGT0Oivu
37
37
  python_minifier/transforms/remove_pass.py,sha256=S9e59nBEZ8rBBifvAhbPRDTfUA7s8_a7pSIsZbFZD2A,735
38
38
  python_minifier/transforms/remove_posargs.py,sha256=aV0wFnGiDXu4uQBQP7-cB1uLSF3mamIq5-txvDg8BVo,314
39
39
  python_minifier/transforms/suite_transformer.py,sha256=WZCVkkBSniWeEtBybVweeMmy-A1wC3lBIYSgxCHelBU,6324
40
- python_minifier-3.1.0.dist-info/LICENSE,sha256=FzsyDHb8pAZupSGFjIOuHcHMlFf6N-aIxq9gOYGbNyE,1069
41
- python_minifier-3.1.0.dist-info/METADATA,sha256=I_DsUDjeg9LVWVlOzWeilaeQEbCINF6I-5BTvnGDSRE,6502
42
- python_minifier-3.1.0.dist-info/WHEEL,sha256=1VPi6hfNQaRRNuEdK_3dv9o8COtLGnHWJghhj4CQ28k,92
43
- python_minifier-3.1.0.dist-info/entry_points.txt,sha256=aS7ZUWQeeys8lAbrmmEa2__Bg-anH1tUMyi9cKdTbO4,60
44
- python_minifier-3.1.0.dist-info/top_level.txt,sha256=4SRDfWKi_KMq7LDrjlzUFoDCs6INYPtxc1Pun4z8LsU,16
45
- python_minifier-3.1.0.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
46
- python_minifier-3.1.0.dist-info/RECORD,,
40
+ python_minifier-3.1.1.dist-info/LICENSE,sha256=FzsyDHb8pAZupSGFjIOuHcHMlFf6N-aIxq9gOYGbNyE,1069
41
+ python_minifier-3.1.1.dist-info/METADATA,sha256=szq8DMXjTaRYTE-tUW8lKyMiojWV2yyu6l2wGSaxu5k,6502
42
+ python_minifier-3.1.1.dist-info/WHEEL,sha256=1VPi6hfNQaRRNuEdK_3dv9o8COtLGnHWJghhj4CQ28k,92
43
+ python_minifier-3.1.1.dist-info/entry_points.txt,sha256=aS7ZUWQeeys8lAbrmmEa2__Bg-anH1tUMyi9cKdTbO4,60
44
+ python_minifier-3.1.1.dist-info/top_level.txt,sha256=4SRDfWKi_KMq7LDrjlzUFoDCs6INYPtxc1Pun4z8LsU,16
45
+ python_minifier-3.1.1.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
46
+ python_minifier-3.1.1.dist-info/RECORD,,