Skip to content

Commit 11f7cb7

Browse files
committed
Replace ufmt with simple usort and black chaining.
1 parent e5f2ef8 commit 11f7cb7

Some content is hidden

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

64 files changed

+128
-75
lines changed

.github/workflows/auto-sync.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ jobs:
2323
pip install .
2424
- name: Check formatting
2525
run: |
26-
ufmt check src/autosync
26+
python3.11 -m usort check src/autosync
27+
python3.11 -m black --check src/autosync
2728
- name: CppTranslator - Patch tests
2829
run: |
2930
python -m unittest discover src/autosync/cpptranslator/Tests/

suite/auto-sync/format_py.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/bash
2+
3+
python3.11 -m usort format src/autosync
4+
python3.11 -m black src/autosync

suite/auto-sync/pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ dependencies = [
55
"termcolor >= 2.3.0",
66
"tree_sitter < 0.22.0",
77
"black >= 24.3.0",
8-
"ufmt >= 2.5.1",
98
"usort >= 1.0.8",
109
"setuptools >= 69.2.0",
1110
]

suite/auto-sync/src/autosync/cpptranslator/Patches/AddCSDetail.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import logging as log
22
import re
33

4+
from tree_sitter import Node
5+
46
from autosync.cpptranslator.Patches.HelperMethods import (
57
get_MCInst_var_name,
68
get_text,
79
template_param_list_to_dict,
810
)
911
from autosync.cpptranslator.Patches.Patch import Patch
1012

11-
from tree_sitter import Node
12-
1313

1414
class AddCSDetail(Patch):
1515
"""

suite/auto-sync/src/autosync/cpptranslator/Patches/AddOperand.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
from tree_sitter import Node
2+
13
from autosync.cpptranslator.Patches.HelperMethods import get_text
24
from autosync.cpptranslator.Patches.Patch import Patch
3-
from tree_sitter import Node
45

56

67
class AddOperand(Patch):

suite/auto-sync/src/autosync/cpptranslator/Patches/Assert.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
from autosync.cpptranslator.Patches.Patch import Patch
21
from tree_sitter import Node
32

3+
from autosync.cpptranslator.Patches.Patch import Patch
4+
45

56
class Assert(Patch):
67
"""

suite/auto-sync/src/autosync/cpptranslator/Patches/BitCastStdArray.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
from tree_sitter import Node
2+
13
from autosync.cpptranslator.Patches.HelperMethods import get_text
24
from autosync.cpptranslator.Patches.Patch import Patch
3-
from tree_sitter import Node
45

56

67
class BitCastStdArray(Patch):

suite/auto-sync/src/autosync/cpptranslator/Patches/CheckDecoderStatus.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
from tree_sitter import Node
2+
13
from autosync.cpptranslator.Patches.HelperMethods import get_text
24
from autosync.cpptranslator.Patches.Patch import Patch
3-
from tree_sitter import Node
45

56

67
class CheckDecoderStatus(Patch):

suite/auto-sync/src/autosync/cpptranslator/Patches/ClassConstructorDef.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
from autosync.cpptranslator.Patches.Patch import Patch
21
from tree_sitter import Node
32

3+
from autosync.cpptranslator.Patches.Patch import Patch
4+
45

56
class ClassConstructorDef(Patch):
67
"""

suite/auto-sync/src/autosync/cpptranslator/Patches/ClassesDef.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import logging as log
22
import re
33

4+
from tree_sitter import Node
5+
46
from autosync.cpptranslator.Patches.HelperMethods import get_text
57
from autosync.cpptranslator.Patches.Patch import Patch
68

7-
from tree_sitter import Node
8-
99

1010
class ClassesDef(Patch):
1111
"""

suite/auto-sync/src/autosync/cpptranslator/Patches/ConstMCInstParameter.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
from tree_sitter import Node
2+
13
from autosync.cpptranslator.Patches.HelperMethods import get_text
24
from autosync.cpptranslator.Patches.Patch import Patch
3-
from tree_sitter import Node
45

56

67
class ConstMCInstParameter(Patch):

suite/auto-sync/src/autosync/cpptranslator/Patches/ConstMCOperand.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
from tree_sitter import Node
2+
13
from autosync.cpptranslator.Patches.HelperMethods import get_text
24
from autosync.cpptranslator.Patches.Patch import Patch
3-
from tree_sitter import Node
45

56

67
class ConstMCOperand(Patch):

suite/auto-sync/src/autosync/cpptranslator/Patches/CppInitCast.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
from tree_sitter import Node
2+
13
from autosync.cpptranslator.Patches.HelperMethods import get_text
24
from autosync.cpptranslator.Patches.Patch import Patch
3-
from tree_sitter import Node
45

56

67
class CppInitCast(Patch):

suite/auto-sync/src/autosync/cpptranslator/Patches/CreateOperand0.py

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

3+
from tree_sitter import Node
4+
35
from autosync.cpptranslator.Patches.HelperMethods import get_text
46
from autosync.cpptranslator.Patches.Patch import Patch
57

6-
from tree_sitter import Node
7-
88

99
class CreateOperand0(Patch):
1010
"""

suite/auto-sync/src/autosync/cpptranslator/Patches/CreateOperand1.py

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

3+
from tree_sitter import Node
4+
35
from autosync.cpptranslator.Patches.HelperMethods import get_MCInst_var_name, get_text
46
from autosync.cpptranslator.Patches.Patch import Patch
57

6-
from tree_sitter import Node
7-
88

99
class CreateOperand1(Patch):
1010
"""

suite/auto-sync/src/autosync/cpptranslator/Patches/DeclarationInConditionClause.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
from tree_sitter import Node
2+
13
from autosync.cpptranslator.Patches.HelperMethods import get_capture_node, get_text
24
from autosync.cpptranslator.Patches.Patch import Patch
3-
from tree_sitter import Node
45

56

67
class DeclarationInConditionalClause(Patch):

suite/auto-sync/src/autosync/cpptranslator/Patches/DecodeInstruction.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
from tree_sitter import Node
2+
13
from autosync.cpptranslator.Patches.HelperMethods import get_text
24
from autosync.cpptranslator.Patches.Patch import Patch
3-
from tree_sitter import Node
45

56

67
class DecodeInstruction(Patch):

suite/auto-sync/src/autosync/cpptranslator/Patches/DecoderCast.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
from autosync.cpptranslator.Patches.Patch import Patch
21
from tree_sitter import Node
32

3+
from autosync.cpptranslator.Patches.Patch import Patch
4+
45

56
class DecoderCast(Patch):
67
"""

suite/auto-sync/src/autosync/cpptranslator/Patches/DecoderParameter.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
from autosync.cpptranslator.Patches.Patch import Patch
21
from tree_sitter import Node
32

3+
from autosync.cpptranslator.Patches.Patch import Patch
4+
45

56
class DecoderParameter(Patch):
67
"""

suite/auto-sync/src/autosync/cpptranslator/Patches/FallThrough.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
from autosync.cpptranslator.Patches.Patch import Patch
21
from tree_sitter import Node
32

3+
from autosync.cpptranslator.Patches.Patch import Patch
4+
45

56
class FallThrough(Patch):
67
"""

suite/auto-sync/src/autosync/cpptranslator/Patches/FeatureBits.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
from tree_sitter import Node
2+
13
from autosync.cpptranslator.Patches.HelperMethods import get_MCInst_var_name, get_text
24
from autosync.cpptranslator.Patches.Patch import Patch
3-
from tree_sitter import Node
45

56

67
class FeatureBits(Patch):

suite/auto-sync/src/autosync/cpptranslator/Patches/FeatureBitsDecl.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
from autosync.cpptranslator.Patches.Patch import Patch
21
from tree_sitter import Node
32

3+
from autosync.cpptranslator.Patches.Patch import Patch
4+
45

56
class FeatureBitsDecl(Patch):
67
"""

suite/auto-sync/src/autosync/cpptranslator/Patches/FieldFromInstr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import logging as log
22
import re
33

4+
from tree_sitter import Node
5+
46
from autosync.cpptranslator.Patches.HelperMethods import (
57
get_function_params_of_node,
68
get_text,
79
)
810
from autosync.cpptranslator.Patches.Patch import Patch
911

10-
from tree_sitter import Node
11-
1212

1313
class FieldFromInstr(Patch):
1414
"""

suite/auto-sync/src/autosync/cpptranslator/Patches/GetNumOperands.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
from tree_sitter import Node
2+
13
from autosync.cpptranslator.Patches.HelperMethods import get_text
24
from autosync.cpptranslator.Patches.Patch import Patch
3-
from tree_sitter import Node
45

56

67
class GetNumOperands(Patch):

suite/auto-sync/src/autosync/cpptranslator/Patches/GetOpcode.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
from tree_sitter import Node
2+
13
from autosync.cpptranslator.Patches.HelperMethods import get_text
24
from autosync.cpptranslator.Patches.Patch import Patch
3-
from tree_sitter import Node
45

56

67
class GetOpcode(Patch):

suite/auto-sync/src/autosync/cpptranslator/Patches/GetOperand.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
from tree_sitter import Node
2+
13
from autosync.cpptranslator.Patches.HelperMethods import get_text
24
from autosync.cpptranslator.Patches.Patch import Patch
3-
from tree_sitter import Node
45

56

67
class GetOperand(Patch):

suite/auto-sync/src/autosync/cpptranslator/Patches/GetOperandRegImm.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
from tree_sitter import Node
2+
13
from autosync.cpptranslator.Patches.HelperMethods import get_capture_node, get_text
24
from autosync.cpptranslator.Patches.Patch import Patch
3-
from tree_sitter import Node
45

56

67
class GetOperandRegImm(Patch):

suite/auto-sync/src/autosync/cpptranslator/Patches/GetRegClass.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
from tree_sitter import Node
2+
13
from autosync.cpptranslator.Patches.HelperMethods import (
24
get_capture_node,
35
get_MCInst_var_name,
46
get_text,
57
)
68
from autosync.cpptranslator.Patches.Patch import Patch
7-
from tree_sitter import Node
89

910

1011
class GetRegClass(Patch):

suite/auto-sync/src/autosync/cpptranslator/Patches/GetRegFromClass.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
from tree_sitter import Node
2+
13
from autosync.cpptranslator.Patches.HelperMethods import get_capture_node, get_text
24
from autosync.cpptranslator.Patches.Patch import Patch
3-
from tree_sitter import Node
45

56

67
class GetRegFromClass(Patch):

suite/auto-sync/src/autosync/cpptranslator/Patches/GetSubReg.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
from tree_sitter import Node
2+
13
from autosync.cpptranslator.Patches.HelperMethods import get_MCInst_var_name, get_text
24
from autosync.cpptranslator.Patches.Patch import Patch
3-
from tree_sitter import Node
45

56

67
class GetSubReg(Patch):

suite/auto-sync/src/autosync/cpptranslator/Patches/HelperMethods.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import logging as log
22
import re
33

4-
from autosync.Helper import fail_exit
5-
64
from tree_sitter import Node
75

6+
from autosync.Helper import fail_exit
7+
88

99
def get_function_params_of_node(n: Node) -> Node:
1010
"""

suite/auto-sync/src/autosync/cpptranslator/Patches/Includes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import logging as log
22

3+
from tree_sitter import Node
4+
35
from autosync.cpptranslator.Patches.HelperMethods import get_text
46
from autosync.cpptranslator.Patches.Patch import Patch
57

6-
from tree_sitter import Node
7-
88

99
class Includes(Patch):
1010
"""

suite/auto-sync/src/autosync/cpptranslator/Patches/InlineToStaticInline.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
from tree_sitter import Node
2+
13
from autosync.cpptranslator.Patches.HelperMethods import get_text
24
from autosync.cpptranslator.Patches.Patch import Patch
3-
from tree_sitter import Node
45

56

67
class InlineToStaticInline(Patch):

suite/auto-sync/src/autosync/cpptranslator/Patches/IsOptionalDef.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
from tree_sitter import Node
2+
13
from autosync.cpptranslator.Patches.HelperMethods import get_text
24
from autosync.cpptranslator.Patches.Patch import Patch
3-
from tree_sitter import Node
45

56

67
class IsOptionalDef(Patch):

suite/auto-sync/src/autosync/cpptranslator/Patches/IsPredicate.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
from tree_sitter import Node
2+
13
from autosync.cpptranslator.Patches.HelperMethods import get_text
24
from autosync.cpptranslator.Patches.Patch import Patch
3-
from tree_sitter import Node
45

56

67
class IsPredicate(Patch):

suite/auto-sync/src/autosync/cpptranslator/Patches/IsRegImm.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
from tree_sitter import Node
2+
13
from autosync.cpptranslator.Patches.HelperMethods import get_text
24
from autosync.cpptranslator.Patches.Patch import Patch
3-
from tree_sitter import Node
45

56

67
class IsOperandRegImm(Patch):

suite/auto-sync/src/autosync/cpptranslator/Patches/LLVMFallThrough.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
from autosync.cpptranslator.Patches.Patch import Patch
21
from tree_sitter import Node
32

3+
from autosync.cpptranslator.Patches.Patch import Patch
4+
45

56
class LLVMFallThrough(Patch):
67
"""

suite/auto-sync/src/autosync/cpptranslator/Patches/LLVMunreachable.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
from tree_sitter import Node
2+
13
from autosync.cpptranslator.Patches.HelperMethods import get_text
24
from autosync.cpptranslator.Patches.Patch import Patch
3-
from tree_sitter import Node
45

56

67
class LLVMUnreachable(Patch):

suite/auto-sync/src/autosync/cpptranslator/Patches/MethodToFunctions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
from tree_sitter import Node
2+
13
from autosync.cpptranslator.Patches.HelperMethods import get_text
24
from autosync.cpptranslator.Patches.Patch import Patch
3-
from tree_sitter import Node
45

56

67
class MethodToFunction(Patch):

suite/auto-sync/src/autosync/cpptranslator/Patches/MethodTypeQualifier.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
from tree_sitter import Node
2+
13
from autosync.cpptranslator.Patches.HelperMethods import get_text
24
from autosync.cpptranslator.Patches.Patch import Patch
3-
from tree_sitter import Node
45

56

67
class MethodTypeQualifier(Patch):

0 commit comments

Comments
 (0)