Add isort to CI and run on files

This commit is contained in:
gregorni 2023-07-09 14:26:37 +00:00 committed by James Westman
parent f526cfa4d9
commit 3730e2e726
45 changed files with 112 additions and 113 deletions

View file

@ -17,9 +17,9 @@
#
# SPDX-License-Identifier: LGPL-3.0-or-later
import typing as T
from collections import ChainMap, defaultdict
from functools import cached_property
import typing as T
from .errors import *
from .lsp_utils import SemanticToken

View file

@ -20,12 +20,12 @@
import typing as T
from . import gir, language
from .language.types import ClassName
from .ast_utils import AstNode
from .completions_utils import *
from .language.types import ClassName
from .lsp_utils import Completion, CompletionItemKind
from .parser import SKIP_TOKENS
from .tokenizer import TokenType, Token
from .tokenizer import Token, TokenType
Pattern = T.List[T.Tuple[TokenType, T.Optional[str]]]

View file

@ -20,9 +20,8 @@
import typing as T
from .tokenizer import Token, TokenType
from .lsp_utils import Completion
from .tokenizer import Token, TokenType
new_statement_patterns = [
[(TokenType.PUNCTUATION, "{")],

View file

@ -18,14 +18,13 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
import re
from enum import Enum
import typing as T
from dataclasses import dataclass
from enum import Enum
from .xml_reader import Element, parse, parse_string
from .gir import *
from .utils import Colors
from .xml_reader import Element, parse, parse_string
__all__ = ["decompile"]

View file

@ -17,9 +17,11 @@
#
# SPDX-License-Identifier: LGPL-3.0-or-later
from dataclasses import dataclass
import sys
import traceback
import typing as T
import sys, traceback
from dataclasses import dataclass
from . import utils
from .utils import Colors

View file

@ -17,17 +17,18 @@
#
# SPDX-License-Identifier: LGPL-3.0-or-later
from functools import cached_property
import os
import sys
import typing as T
import os, sys
from functools import cached_property
import gi # type: ignore
gi.require_version("GIRepository", "2.0")
from gi.repository import GIRepository # type: ignore
from .errors import CompileError, CompilerBugError
from . import typelib, xml_reader
from .errors import CompileError, CompilerBugError
_namespace_cache: T.Dict[str, "Namespace"] = {}
_xml_cache = {}

View file

@ -18,16 +18,15 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
import typing as T
import difflib
import os
import typing as T
from . import decompiler, tokenizer, parser
from . import decompiler, parser, tokenizer
from .errors import CompilerBugError, MultipleErrors, PrintableError
from .outputs.xml import XmlOutput
from .errors import MultipleErrors, PrintableError, CompilerBugError
from .utils import Colors
# A tool to interactively port projects to blueprints.

View file

@ -1,12 +1,12 @@
from .gtk_list_item_factory import ExtListItemFactory
from .adw_breakpoint import (
AdwBreakpointCondition,
AdwBreakpointSetter,
AdwBreakpointSetters,
)
from .adw_message_dialog import ExtAdwMessageDialog
from .attributes import BaseAttribute
from .adw_breakpoint import (
AdwBreakpointSetters,
AdwBreakpointSetter,
AdwBreakpointCondition,
)
from .binding import Binding
from .common import *
from .contexts import ScopeCtx, ValueTypeCtx
from .expression import (
CastExpr,
@ -23,23 +23,24 @@ from .gobject_signal import Signal
from .gtk_a11y import ExtAccessibility
from .gtk_combo_box_text import ExtComboBoxItems
from .gtk_file_filter import (
Filters,
ext_file_filter_mime_types,
ext_file_filter_patterns,
ext_file_filter_suffixes,
Filters,
)
from .gtk_layout import ExtLayout
from .gtk_menu import menu, Menu, MenuAttribute
from .gtk_list_item_factory import ExtListItemFactory
from .gtk_menu import Menu, MenuAttribute, menu
from .gtk_scale import ExtScaleMarks
from .gtk_size_group import ExtSizeGroupWidgets
from .gtk_string_list import ExtStringListStrings
from .gtk_styles import ExtStyles
from .gtkbuilder_child import Child, ChildType, ChildInternal, ChildExtension
from .gtkbuilder_child import Child, ChildExtension, ChildInternal, ChildType
from .gtkbuilder_template import Template
from .imports import GtkDirective, Import
from .property_binding import PropertyBinding
from .ui import UI
from .types import ClassName
from .ui import UI
from .values import (
Flag,
Flags,
@ -54,8 +55,6 @@ from .values import (
Value,
)
from .common import *
OBJECT_CONTENT_HOOKS.children = [
Signal,
Property,

View file

@ -18,7 +18,7 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
from ..decompiler import truthy, decompile_translatable
from ..decompiler import decompile_translatable, truthy
from .common import *
from .contexts import ValueTypeCtx
from .gobject_object import ObjectContent, validate_parent_type

View file

@ -20,7 +20,7 @@
from dataclasses import dataclass
from .common import *
from .expression import Expression, LookupOp, LiteralExpr
from .expression import Expression, LiteralExpr, LookupOp
class Binding(AstNode):

View file

@ -18,36 +18,35 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
from .. import gir
from ..ast_utils import AstNode, validate, docs, context
from ..errors import (
CompileError,
MultipleErrors,
UpgradeWarning,
CompileWarning,
CodeAction,
)
from ..completions_utils import *
from .. import decompiler as decompile
from .. import gir
from ..ast_utils import AstNode, context, docs, validate
from ..completions_utils import *
from ..decompiler import (
DecompileCtx,
decompile_translatable,
decompiler,
escape_quote,
truthy,
decompile_translatable,
)
from ..errors import (
CodeAction,
CompileError,
CompileWarning,
MultipleErrors,
UpgradeWarning,
)
from ..gir import (
StringType,
BoolType,
IntType,
FloatType,
GirType,
Enumeration,
ExternType,
FloatType,
GirType,
IntType,
StringType,
)
from ..lsp_utils import Completion, CompletionItemKind, SemanticToken, SemanticTokenType
from ..parse_tree import *
OBJECT_CONTENT_HOOKS = AnyOf()
LITERAL = AnyOf()

View file

@ -38,8 +38,8 @@ class ScopeCtx:
@cached_property
def template(self):
from .ui import UI
from .gtk_list_item_factory import ExtListItemFactory
from .ui import UI
if isinstance(self.node, UI):
return self.node.template

View file

@ -20,9 +20,8 @@
from .common import *
from .contexts import ScopeCtx, ValueTypeCtx
from .types import TypeName
from .gtkbuilder_template import Template
from .types import TypeName
expr = Sequence()

View file

@ -25,7 +25,6 @@ from .common import *
from .response_id import ExtResponse
from .types import ClassName, ConcreteClassName
RESERVED_IDS = {"this", "self", "template", "true", "false", "null", "none"}

View file

@ -18,12 +18,12 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
from .gtkbuilder_template import Template
from .values import Value, ObjectValue
from .binding import Binding
from .common import *
from .contexts import ValueTypeCtx
from .gtkbuilder_template import Template
from .property_binding import PropertyBinding
from .binding import Binding
from .values import ObjectValue, Value
class Property(AstNode):

View file

@ -19,9 +19,9 @@
import typing as T
from .gtkbuilder_template import Template
from .contexts import ScopeCtx
from .common import *
from .contexts import ScopeCtx
from .gtkbuilder_template import Template
class SignalFlag(AstNode):

View file

@ -17,12 +17,12 @@
#
# SPDX-License-Identifier: LGPL-3.0-or-later
from .gobject_object import ObjectContent, validate_parent_type
from ..decompiler import escape_quote
from .attributes import BaseAttribute
from .values import Value
from .common import *
from .contexts import ValueTypeCtx
from ..decompiler import escape_quote
from .gobject_object import ObjectContent, validate_parent_type
from .values import Value
def get_property_types(gir):

View file

@ -18,9 +18,9 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
from .gobject_object import ObjectContent, validate_parent_type
from .common import *
from .contexts import ValueTypeCtx
from .gobject_object import ObjectContent, validate_parent_type
from .values import StringValue

View file

@ -18,8 +18,8 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
from .gobject_object import ObjectContent, validate_parent_type
from .common import *
from .gobject_object import ObjectContent, validate_parent_type
class Filters(AstNode):

View file

@ -18,9 +18,9 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
from .gobject_object import ObjectContent, validate_parent_type
from .common import *
from .contexts import ValueTypeCtx
from .gobject_object import ObjectContent, validate_parent_type
from .values import Value

View file

@ -1,9 +1,9 @@
from .gobject_object import ObjectContent, validate_parent_type
from ..parse_tree import Keyword
from ..ast_utils import AstNode, validate
from ..parse_tree import Keyword
from .common import *
from .types import TypeName
from .contexts import ScopeCtx
from .gobject_object import ObjectContent, validate_parent_type
from .types import TypeName
class ExtListItemFactory(AstNode):

View file

@ -17,8 +17,8 @@
#
# SPDX-License-Identifier: LGPL-3.0-or-later
from .gobject_object import validate_parent_type, ObjectContent
from .common import *
from .gobject_object import ObjectContent, validate_parent_type
from .values import StringValue

View file

@ -18,9 +18,9 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
from .gobject_object import ObjectContent, validate_parent_type
from .common import *
from .contexts import ScopeCtx
from .gobject_object import ObjectContent, validate_parent_type
class Widget(AstNode):

View file

@ -18,9 +18,9 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
from .common import *
from .gobject_object import ObjectContent, validate_parent_type
from .values import StringValue
from .common import *
class Item(AstNode):

View file

@ -18,8 +18,8 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
from .gobject_object import ObjectContent, validate_parent_type
from .common import *
from .gobject_object import ObjectContent, validate_parent_type
class StyleClass(AstNode):

View file

@ -20,9 +20,9 @@
from functools import cached_property
from .common import *
from .gobject_object import Object
from .response_id import ExtResponse
from .common import *
ALLOWED_PARENTS: T.List[T.Tuple[str, str]] = [
("Gtk", "Buildable"),

View file

@ -21,9 +21,9 @@ import typing as T
from blueprintcompiler.language.common import GirType
from .gobject_object import Object, ObjectContent
from .common import *
from ..gir import TemplateType
from .common import *
from .gobject_object import Object, ObjectContent
from .types import ClassName, TemplateClassName

View file

@ -18,8 +18,8 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
from .common import *
from ..gir import Class, ExternType, Interface
from .common import *
class TypeName(AstNode):

View file

@ -20,12 +20,12 @@
from functools import cached_property
from .. import gir
from .imports import GtkDirective, Import
from .gtkbuilder_template import Template
from .gobject_object import Object
from .gtk_menu import menu, Menu
from .common import *
from .contexts import ScopeCtx
from .gobject_object import Object
from .gtk_menu import Menu, menu
from .gtkbuilder_template import Template
from .imports import GtkDirective, Import
class UI(AstNode):

View file

@ -20,9 +20,9 @@
import typing as T
from .common import *
from .types import TypeName
from .gobject_object import Object
from .contexts import ScopeCtx, ValueTypeCtx
from .gobject_object import Object
from .types import TypeName
class Translated(AstNode):

View file

@ -18,14 +18,16 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
import json
import sys
import traceback
import typing as T
import json, sys, traceback
from . import decompiler, parser, tokenizer, utils, xml_reader
from .completions import complete
from .errors import PrintableError, CompileError, MultipleErrors
from .errors import CompileError, MultipleErrors, PrintableError
from .lsp_utils import *
from .outputs.xml import XmlOutput
from . import tokenizer, parser, utils, xml_reader, decompiler
def printerr(*args, **kwargs):

View file

@ -18,9 +18,9 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
from dataclasses import dataclass
import enum
import typing as T
from dataclasses import dataclass
from .errors import *
from .utils import *

View file

@ -18,15 +18,18 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
import argparse
import json
import os
import sys
import typing as T
import argparse, json, os, sys
from .errors import PrintableError, report_bug, MultipleErrors, CompilerBugError
from . import decompiler, interactive_port, parser, tokenizer
from .errors import CompilerBugError, MultipleErrors, PrintableError, report_bug
from .gir import add_typelib_search_path
from .lsp import LanguageServer
from . import parser, tokenizer, decompiler, interactive_port
from .utils import Colors
from .outputs import XmlOutput
from .utils import Colors
VERSION = "uninstalled"
LIBDIR = None

View file

@ -1,7 +1,7 @@
import typing as T
from .. import OutputFormat
from ...language import *
from .. import OutputFormat
from .xml_emitter import XmlEmitter

View file

@ -18,7 +18,6 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
import typing as T
from xml.sax import saxutils
from blueprintcompiler.gir import GirType

View file

@ -20,21 +20,19 @@
""" Utilities for parsing an AST from a token stream. """
import typing as T
from collections import defaultdict
from enum import Enum
from .ast_utils import AstNode
from .ast_utils import AstNode
from .errors import (
assert_true,
CompilerBugError,
CompileError,
CompilerBugError,
CompileWarning,
UnexpectedTokenError,
assert_true,
)
from .tokenizer import Token, TokenType
SKIP_TOKENS = [TokenType.COMMENT, TokenType.WHITESPACE]

View file

@ -19,9 +19,9 @@
from .errors import MultipleErrors, PrintableError
from .language import OBJECT_CONTENT_HOOKS, UI, Template
from .parse_tree import *
from .tokenizer import TokenType
from .language import OBJECT_CONTENT_HOOKS, Template, UI
def parse(

View file

@ -18,8 +18,8 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
import typing as T
import re
import typing as T
from enum import Enum
from .errors import CompileError, CompilerBugError

View file

@ -17,15 +17,15 @@
#
# SPDX-License-Identifier: LGPL-3.0-or-later
import math
import mmap
import os
import sys
import typing as T
import math
from ctypes import *
import mmap, os
from .errors import CompilerBugError
BLOB_TYPE_STRUCT = 3
BLOB_TYPE_BOXED = 4
BLOB_TYPE_ENUM = 5

View file

@ -18,12 +18,11 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
import typing as T
from collections import defaultdict
from functools import cached_property
import typing as T
from xml import sax
# To speed up parsing, we ignore all tags except these
PARSE_GIR = set(
[