Skip to content

Commit 6e80593

Browse files
committed
Sort imports
1 parent 0ada486 commit 6e80593

61 files changed

Lines changed: 191 additions & 97 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

corpus_test/__init__.py

Whitespace-only changes.

corpus_test/generate_report.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import argparse
22
import os
33
import sys
4+
45
from dataclasses import dataclass, field
56
from typing import Iterable
67

7-
from result import Result, ResultReader
8+
from .result import Result, ResultReader
89

910
ENHANCED_REPORT = os.environ.get('ENHANCED_REPORT', True)
1011

corpus_test/generate_results.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
import argparse
22
import datetime
33
import gzip
4+
import logging
45
import os
56
import sys
67
import time
78

8-
9-
import logging
10-
11-
129
import python_minifier
13-
from result import Result, ResultWriter
10+
11+
from .result import Result, ResultWriter
1412

1513
try:
1614
RE = RecursionError

hypo_test/__init__.py

Whitespace-only changes.

hypo_test/expressions.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,23 @@
55
import unicodedata
66

77
from hypothesis import assume
8-
from hypothesis.strategies import integers, lists, binary, sampled_from, recursive, dictionaries, booleans, SearchStrategy, text, composite, one_of, floats, complex_numbers, characters, none
8+
from hypothesis.strategies import (
9+
SearchStrategy,
10+
binary,
11+
booleans,
12+
characters,
13+
complex_numbers,
14+
composite,
15+
dictionaries,
16+
floats,
17+
integers,
18+
lists,
19+
none,
20+
one_of,
21+
recursive,
22+
sampled_from,
23+
text
24+
)
925

1026
comparison_operators = sampled_from([
1127
ast.Eq(),

hypo_test/folding.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
from hypothesis import assume
2-
from hypothesis.strategies import integers, lists, binary, sampled_from, recursive, dictionaries, booleans, SearchStrategy, text, composite, one_of, floats, complex_numbers, characters, none
31
import ast
42

5-
from expressions import NameConstant, Num
3+
from hypothesis.strategies import SearchStrategy, composite, lists, recursive, sampled_from
4+
5+
from .expressions import NameConstant, Num
66

77
leaves = NameConstant() | Num()
88

hypo_test/module.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import ast
22

33
from hypothesis import assume
4-
from hypothesis.strategies import integers, lists, sampled_from, recursive, none, booleans, SearchStrategy, composite, one_of
4+
from hypothesis.strategies import SearchStrategy, booleans, composite, integers, lists, none, one_of, recursive, sampled_from
5+
6+
from .expressions import Name, arguments, expression, name
57

6-
from hypo_test.expressions import Name, expression, name
7-
from expressions import arguments
88

99
@composite
1010
def Assign(draw) -> ast.Assign:
@@ -193,7 +193,7 @@ def FunctionDef(draw, statements) -> ast.FunctionDef:
193193
args = draw(arguments())
194194
body = draw(lists(statements, min_size=1, max_size=3))
195195
decorator_list = draw(lists(Name(), min_size=0, max_size=2))
196-
type_params = draw(none() | lists(one_of(TypeVar(), TypeVarTuple(), ParamSpec()), min_size=0, max_size=3))
196+
type_params = draw(lists(one_of(TypeVar(), TypeVarTuple(), ParamSpec()), min_size=0, max_size=3))
197197
returns = draw(none() | expression())
198198
return ast.FunctionDef(n, args, body, decorator_list, returns, type_params=type_params)
199199

@@ -203,7 +203,7 @@ def AsyncFunctionDef(draw, statements) -> ast.AsyncFunctionDef:
203203
args = draw(arguments())
204204
body = draw(lists(statements, min_size=1, max_size=3))
205205
decorator_list = draw(lists(Name(), min_size=0, max_size=2))
206-
type_params = draw(none() | lists(one_of(TypeVar(), TypeVarTuple(), ParamSpec()), min_size=0, max_size=3))
206+
type_params = draw(lists(one_of(TypeVar(), TypeVarTuple(), ParamSpec()), min_size=0, max_size=3))
207207
returns = draw(none() | expression())
208208
return ast.AsyncFunctionDef(n, args, body, decorator_list, returns, type_params=type_params)
209209

@@ -230,7 +230,7 @@ def ClassDef(draw, statements) -> ast.ClassDef:
230230
keywords=keywords,
231231
body=body,
232232
decorator_list=decorator_list,
233-
type_params=draw(none() | lists(one_of(TypeVar(), TypeVarTuple(), ParamSpec()), min_size=0, max_size=3))
233+
type_params=draw(lists(one_of(TypeVar(), TypeVarTuple(), ParamSpec()), min_size=0, max_size=3))
234234
)
235235

236236
if hasattr(ast, 'Print'):
@@ -286,7 +286,7 @@ def suite() -> SearchStrategy:
286286
ClassDef(statements),
287287
Try(statements)
288288
),
289-
max_leaves=150
289+
max_leaves=100
290290
)
291291

292292
@composite

hypo_test/patterns.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
import string
44

55
from hypothesis import assume
6-
from hypothesis.strategies import lists, sampled_from, recursive, text, composite, one_of, none, booleans, integers
6+
from hypothesis.strategies import booleans, composite, integers, lists, none, one_of, recursive, sampled_from, text
7+
78

89
@composite
910
def name(draw):

hypo_test/test_it.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
import ast
22

33
from datetime import timedelta
4-
from hypothesis import given, settings, Verbosity, note, HealthCheck
54

6-
from folding import FoldableExpression
7-
from patterns import Pattern
8-
from python_minifier import ModulePrinter
5+
from hypothesis import HealthCheck, Verbosity, given, note, settings
6+
97
from python_minifier.ast_compare import compare_ast
108
from python_minifier.ast_printer import print_ast
119
from python_minifier.expression_printer import ExpressionPrinter
12-
from expressions import Expression
13-
from module import Module, TypeAlias
10+
from python_minifier.module_printer import ModulePrinter
1411
from python_minifier.rename.mapper import add_parent
1512
from python_minifier.transforms.constant_folding import FoldConstants
1613

14+
from .expressions import Expression
15+
from .folding import FoldableExpression
16+
from .module import Module, TypeAlias
17+
from .patterns import Pattern
18+
1719

1820
@given(node=Expression())
1921
@settings(report_multiple_bugs=False, deadline=timedelta(seconds=1), max_examples=100, suppress_health_check=[HealthCheck.too_slow]) #verbosity=Verbosity.verbose
@@ -28,7 +30,7 @@ def test_expression(node):
2830

2931

3032
@given(node=Module())
31-
@settings(report_multiple_bugs=False, deadline=timedelta(seconds=1), max_examples=100, suppress_health_check=[HealthCheck.too_slow]) #verbosity=Verbosity.verbose
33+
@settings(report_multiple_bugs=False, deadline=timedelta(seconds=1), max_examples=100, suppress_health_check=[HealthCheck.too_slow], verbosity=Verbosity.verbose)
3234
def test_module(node):
3335
assert isinstance(node, ast.Module)
3436

@@ -61,7 +63,7 @@ def test_pattern(node):
6163
compare_ast(module, ast.parse(code, 'test_pattern'))
6264

6365
@given(node=FoldableExpression())
64-
@settings(report_multiple_bugs=False, deadline=timedelta(seconds=1), max_examples=100000, suppress_health_check=[HealthCheck.too_slow]) #verbosity=Verbosity.verbose
66+
@settings(report_multiple_bugs=False, deadline=timedelta(seconds=1), max_examples=1000, suppress_health_check=[HealthCheck.too_slow]) #verbosity=Verbosity.verbose
6567
def test_folding(node):
6668
assert isinstance(node, ast.AST)
6769
note(print_ast(node))
@@ -74,7 +76,7 @@ def test_folding(node):
7476
constant_folder(node)
7577

7678
@given(node=TypeAlias())
77-
@settings(report_multiple_bugs=False, deadline=timedelta(seconds=2), max_examples=1000, verbosity=Verbosity.verbose)
79+
@settings(report_multiple_bugs=False, deadline=timedelta(seconds=2), max_examples=100, verbosity=Verbosity.verbose)
7880
def test_type_alias(node):
7981

8082
module = ast.Module(
@@ -88,7 +90,7 @@ def test_type_alias(node):
8890
compare_ast(module, ast.parse(code, 'test_type_alias'))
8991

9092
@given(node=TypeAlias())
91-
@settings(report_multiple_bugs=False, deadline=timedelta(seconds=2), max_examples=1000, verbosity=Verbosity.verbose)
93+
@settings(report_multiple_bugs=False, deadline=timedelta(seconds=2), max_examples=100, verbosity=Verbosity.verbose)
9294
def test_function_type_param(node):
9395

9496
module = ast.Module(

src/python_minifier/__init__.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,29 @@
44
55
"""
66

7-
import python_minifier.ast_compat as ast
87
import re
98

9+
import python_minifier.ast_compat as ast
10+
1011
from python_minifier.ast_compare import CompareError, compare_ast
1112
from python_minifier.module_printer import ModulePrinter
1213
from python_minifier.rename import (
13-
rename_literals,
14-
bind_names,
15-
resolve_names,
16-
rename,
14+
add_namespace,
1715
allow_rename_globals,
1816
allow_rename_locals,
19-
add_namespace,
17+
bind_names,
18+
rename,
19+
rename_literals,
20+
resolve_names
2021
)
21-
2222
from python_minifier.transforms.combine_imports import CombineImports
2323
from python_minifier.transforms.constant_folding import FoldConstants
2424
from python_minifier.transforms.remove_annotations import RemoveAnnotations
2525
from python_minifier.transforms.remove_annotations_options import RemoveAnnotationsOptions
2626
from python_minifier.transforms.remove_asserts import RemoveAsserts
2727
from python_minifier.transforms.remove_debug import RemoveDebug
28-
from python_minifier.transforms.remove_explicit_return_none import RemoveExplicitReturnNone
2928
from python_minifier.transforms.remove_exception_brackets import remove_no_arg_exception_call
29+
from python_minifier.transforms.remove_explicit_return_none import RemoveExplicitReturnNone
3030
from python_minifier.transforms.remove_literal_statements import RemoveLiteralStatements
3131
from python_minifier.transforms.remove_object_base import RemoveObject
3232
from python_minifier.transforms.remove_pass import RemovePass

0 commit comments

Comments
 (0)