Skip to content

Commit f2b92a0

Browse files
Fix some pylint problems.
1 parent 47e49c1 commit f2b92a0

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

gdtoolkit/common/ast.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from ..formatter.annotation import STANDALONE_ANNOTATIONS
77

88
from .utils import find_name_token_among_children, find_tree_among_children
9+
from .exceptions import GDToolkitError
910

1011

1112
# pylint: disable-next=too-few-public-methods
@@ -113,7 +114,7 @@ def __init__(self, parse_tree: Tree):
113114
elif parse_tree.data == "class_def":
114115
self._load_data_from_class_def(parse_tree)
115116
else:
116-
raise Exception("Cannot load class from that node")
117+
raise GDToolkitError("Cannot load class from that node")
117118

118119
def _load_data_from_node_children(self, node: Tree) -> None:
119120
offset = 1 if node.data == "class_def" else 0

gdtoolkit/common/exceptions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import lark
22

33

4+
class GDToolkitError(Exception):
5+
pass
6+
7+
48
def lark_unexpected_input_to_str(exception: lark.exceptions.UnexpectedInput):
59
return str(exception).strip()
610

gdtoolkit/formatter/exceptions.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
11
from dataclasses import dataclass
22

3+
from ..common.exceptions import GDToolkitError
4+
35

46
@dataclass
5-
class TreeInvariantViolation(Exception):
7+
class TreeInvariantViolation(GDToolkitError):
68
diff: str
79

810
def __str__(self):
911
return '{}(diff="{}")'.format("TreeInvariantViolation", self.diff)
1012

1113

1214
@dataclass
13-
class FormattingStabilityViolation(Exception):
15+
class FormattingStabilityViolation(GDToolkitError):
1416
diff: str
1517

1618
def __str__(self):
1719
return '{}(diff="{}")'.format("FormattingStabilityViolation", self.diff)
1820

1921

2022
@dataclass
21-
class CommentPersistenceViolation(Exception):
23+
class CommentPersistenceViolation(GDToolkitError):
2224
missing_comment: str
2325

2426
def __str__(self):

tests/parser/test_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def test_parsing_failure(gdscript_nok_path):
5858
parser.parse(code)
5959
except: # pylint: disable=bare-except
6060
return
61-
raise Exception("shall fail")
61+
assert True, "shall fail"
6262

6363

6464
@pytest.mark.skipif(shutil.which(GODOT_SERVER) is None, reason="requires godot server")

0 commit comments

Comments
 (0)