Revert "Run isort and black"

This reverts commit 87a8ae96d8.
This commit is contained in:
gregorni 2023-07-09 11:34:39 +02:00
parent 87a8ae96d8
commit 55b6cac27d
42 changed files with 111 additions and 109 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -20,12 +20,12 @@
from functools import cached_property from functools import cached_property
from .. import gir 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 .common import *
from .contexts import ScopeCtx 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): class UI(AstNode):

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,21 +1,20 @@
import os import os, sys
import sys
from pythonfuzz.main import PythonFuzz from pythonfuzz.main import PythonFuzz
from blueprintcompiler.outputs.xml import XmlOutput from blueprintcompiler.outputs.xml import XmlOutput
sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
from blueprintcompiler import decompiler, gir, parser, tokenizer, utils from blueprintcompiler import tokenizer, parser, decompiler, gir
from blueprintcompiler.completions import complete from blueprintcompiler.completions import complete
from blueprintcompiler.errors import ( from blueprintcompiler.errors import (
PrintableError,
MultipleErrors,
CompileError, CompileError,
CompilerBugError, CompilerBugError,
MultipleErrors,
PrintableError,
) )
from blueprintcompiler.tokenizer import Token, TokenType, tokenize from blueprintcompiler.tokenizer import Token, TokenType, tokenize
from blueprintcompiler import utils
@PythonFuzz @PythonFuzz

View file

@ -19,19 +19,20 @@
import difflib # I love Python import difflib # I love Python
import unittest
from pathlib import Path from pathlib import Path
import unittest
import gi import gi
gi.require_version("Gtk", "4.0") gi.require_version("Gtk", "4.0")
from gi.repository import Gtk from gi.repository import Gtk
from blueprintcompiler import decompiler, parser, tokenizer, utils from blueprintcompiler import tokenizer, parser, decompiler
from blueprintcompiler.completions import complete from blueprintcompiler.completions import complete
from blueprintcompiler.errors import CompileError, MultipleErrors, PrintableError from blueprintcompiler.errors import PrintableError, MultipleErrors, CompileError
from blueprintcompiler.outputs.xml import XmlOutput
from blueprintcompiler.tokenizer import Token, TokenType, tokenize from blueprintcompiler.tokenizer import Token, TokenType, tokenize
from blueprintcompiler import utils
from blueprintcompiler.outputs.xml import XmlOutput
class TestSamples(unittest.TestCase): class TestSamples(unittest.TestCase):