Skip to content

Commit

Permalink
Replace ufmt with simple usort and black chaining.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rot127 committed Mar 21, 2024
1 parent e5f2ef8 commit 11f7cb7
Show file tree
Hide file tree
Showing 64 changed files with 128 additions and 75 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/auto-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ jobs:
pip install .
- name: Check formatting
run: |
ufmt check src/autosync
python3.11 -m usort check src/autosync
python3.11 -m black --check src/autosync
- name: CppTranslator - Patch tests
run: |
python -m unittest discover src/autosync/cpptranslator/Tests/
4 changes: 4 additions & 0 deletions suite/auto-sync/format_py.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/bash

python3.11 -m usort format src/autosync
python3.11 -m black src/autosync
1 change: 0 additions & 1 deletion suite/auto-sync/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ dependencies = [
"termcolor >= 2.3.0",
"tree_sitter < 0.22.0",
"black >= 24.3.0",
"ufmt >= 2.5.1",
"usort >= 1.0.8",
"setuptools >= 69.2.0",
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import logging as log
import re

from tree_sitter import Node

from autosync.cpptranslator.Patches.HelperMethods import (
get_MCInst_var_name,
get_text,
template_param_list_to_dict,
)
from autosync.cpptranslator.Patches.Patch import Patch

from tree_sitter import Node


class AddCSDetail(Patch):
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from tree_sitter import Node

from autosync.cpptranslator.Patches.HelperMethods import get_text
from autosync.cpptranslator.Patches.Patch import Patch
from tree_sitter import Node


class AddOperand(Patch):
Expand Down
3 changes: 2 additions & 1 deletion suite/auto-sync/src/autosync/cpptranslator/Patches/Assert.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from autosync.cpptranslator.Patches.Patch import Patch
from tree_sitter import Node

from autosync.cpptranslator.Patches.Patch import Patch


class Assert(Patch):
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from tree_sitter import Node

from autosync.cpptranslator.Patches.HelperMethods import get_text
from autosync.cpptranslator.Patches.Patch import Patch
from tree_sitter import Node


class BitCastStdArray(Patch):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from tree_sitter import Node

from autosync.cpptranslator.Patches.HelperMethods import get_text
from autosync.cpptranslator.Patches.Patch import Patch
from tree_sitter import Node


class CheckDecoderStatus(Patch):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from autosync.cpptranslator.Patches.Patch import Patch
from tree_sitter import Node

from autosync.cpptranslator.Patches.Patch import Patch


class ClassConstructorDef(Patch):
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import logging as log
import re

from tree_sitter import Node

from autosync.cpptranslator.Patches.HelperMethods import get_text
from autosync.cpptranslator.Patches.Patch import Patch

from tree_sitter import Node


class ClassesDef(Patch):
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from tree_sitter import Node

from autosync.cpptranslator.Patches.HelperMethods import get_text
from autosync.cpptranslator.Patches.Patch import Patch
from tree_sitter import Node


class ConstMCInstParameter(Patch):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from tree_sitter import Node

from autosync.cpptranslator.Patches.HelperMethods import get_text
from autosync.cpptranslator.Patches.Patch import Patch
from tree_sitter import Node


class ConstMCOperand(Patch):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from tree_sitter import Node

from autosync.cpptranslator.Patches.HelperMethods import get_text
from autosync.cpptranslator.Patches.Patch import Patch
from tree_sitter import Node


class CppInitCast(Patch):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import re

from tree_sitter import Node

from autosync.cpptranslator.Patches.HelperMethods import get_text
from autosync.cpptranslator.Patches.Patch import Patch

from tree_sitter import Node


class CreateOperand0(Patch):
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import re

from tree_sitter import Node

from autosync.cpptranslator.Patches.HelperMethods import get_MCInst_var_name, get_text
from autosync.cpptranslator.Patches.Patch import Patch

from tree_sitter import Node


class CreateOperand1(Patch):
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from tree_sitter import Node

from autosync.cpptranslator.Patches.HelperMethods import get_capture_node, get_text
from autosync.cpptranslator.Patches.Patch import Patch
from tree_sitter import Node


class DeclarationInConditionalClause(Patch):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from tree_sitter import Node

from autosync.cpptranslator.Patches.HelperMethods import get_text
from autosync.cpptranslator.Patches.Patch import Patch
from tree_sitter import Node


class DecodeInstruction(Patch):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from autosync.cpptranslator.Patches.Patch import Patch
from tree_sitter import Node

from autosync.cpptranslator.Patches.Patch import Patch


class DecoderCast(Patch):
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from autosync.cpptranslator.Patches.Patch import Patch
from tree_sitter import Node

from autosync.cpptranslator.Patches.Patch import Patch


class DecoderParameter(Patch):
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from autosync.cpptranslator.Patches.Patch import Patch
from tree_sitter import Node

from autosync.cpptranslator.Patches.Patch import Patch


class FallThrough(Patch):
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from tree_sitter import Node

from autosync.cpptranslator.Patches.HelperMethods import get_MCInst_var_name, get_text
from autosync.cpptranslator.Patches.Patch import Patch
from tree_sitter import Node


class FeatureBits(Patch):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from autosync.cpptranslator.Patches.Patch import Patch
from tree_sitter import Node

from autosync.cpptranslator.Patches.Patch import Patch


class FeatureBitsDecl(Patch):
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import logging as log
import re

from tree_sitter import Node

from autosync.cpptranslator.Patches.HelperMethods import (
get_function_params_of_node,
get_text,
)
from autosync.cpptranslator.Patches.Patch import Patch

from tree_sitter import Node


class FieldFromInstr(Patch):
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from tree_sitter import Node

from autosync.cpptranslator.Patches.HelperMethods import get_text
from autosync.cpptranslator.Patches.Patch import Patch
from tree_sitter import Node


class GetNumOperands(Patch):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from tree_sitter import Node

from autosync.cpptranslator.Patches.HelperMethods import get_text
from autosync.cpptranslator.Patches.Patch import Patch
from tree_sitter import Node


class GetOpcode(Patch):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from tree_sitter import Node

from autosync.cpptranslator.Patches.HelperMethods import get_text
from autosync.cpptranslator.Patches.Patch import Patch
from tree_sitter import Node


class GetOperand(Patch):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from tree_sitter import Node

from autosync.cpptranslator.Patches.HelperMethods import get_capture_node, get_text
from autosync.cpptranslator.Patches.Patch import Patch
from tree_sitter import Node


class GetOperandRegImm(Patch):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from tree_sitter import Node

from autosync.cpptranslator.Patches.HelperMethods import (
get_capture_node,
get_MCInst_var_name,
get_text,
)
from autosync.cpptranslator.Patches.Patch import Patch
from tree_sitter import Node


class GetRegClass(Patch):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from tree_sitter import Node

from autosync.cpptranslator.Patches.HelperMethods import get_capture_node, get_text
from autosync.cpptranslator.Patches.Patch import Patch
from tree_sitter import Node


class GetRegFromClass(Patch):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from tree_sitter import Node

from autosync.cpptranslator.Patches.HelperMethods import get_MCInst_var_name, get_text
from autosync.cpptranslator.Patches.Patch import Patch
from tree_sitter import Node


class GetSubReg(Patch):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import logging as log
import re

from autosync.Helper import fail_exit

from tree_sitter import Node

from autosync.Helper import fail_exit


def get_function_params_of_node(n: Node) -> Node:
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import logging as log

from tree_sitter import Node

from autosync.cpptranslator.Patches.HelperMethods import get_text
from autosync.cpptranslator.Patches.Patch import Patch

from tree_sitter import Node


class Includes(Patch):
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from tree_sitter import Node

from autosync.cpptranslator.Patches.HelperMethods import get_text
from autosync.cpptranslator.Patches.Patch import Patch
from tree_sitter import Node


class InlineToStaticInline(Patch):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from tree_sitter import Node

from autosync.cpptranslator.Patches.HelperMethods import get_text
from autosync.cpptranslator.Patches.Patch import Patch
from tree_sitter import Node


class IsOptionalDef(Patch):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from tree_sitter import Node

from autosync.cpptranslator.Patches.HelperMethods import get_text
from autosync.cpptranslator.Patches.Patch import Patch
from tree_sitter import Node


class IsPredicate(Patch):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from tree_sitter import Node

from autosync.cpptranslator.Patches.HelperMethods import get_text
from autosync.cpptranslator.Patches.Patch import Patch
from tree_sitter import Node


class IsOperandRegImm(Patch):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from autosync.cpptranslator.Patches.Patch import Patch
from tree_sitter import Node

from autosync.cpptranslator.Patches.Patch import Patch


class LLVMFallThrough(Patch):
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from tree_sitter import Node

from autosync.cpptranslator.Patches.HelperMethods import get_text
from autosync.cpptranslator.Patches.Patch import Patch
from tree_sitter import Node


class LLVMUnreachable(Patch):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from tree_sitter import Node

from autosync.cpptranslator.Patches.HelperMethods import get_text
from autosync.cpptranslator.Patches.Patch import Patch
from tree_sitter import Node


class MethodToFunction(Patch):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from tree_sitter import Node

from autosync.cpptranslator.Patches.HelperMethods import get_text
from autosync.cpptranslator.Patches.Patch import Patch
from tree_sitter import Node


class MethodTypeQualifier(Patch):
Expand Down
Loading

0 comments on commit 11f7cb7

Please sign in to comment.