Skip to content

Commit 8b8c753

Browse files
committed
Fix linter support for docstrings, fixes Scony#233
1 parent 4c382db commit 8b8c753

File tree

5 files changed

+13
-0
lines changed

5 files changed

+13
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- Fixed `max-public-methods` linter check disabling (#222)
1111
- Default regex for names of constants now allows underscore as a prefix to denote private contants (#223)
1212
- Fixed parsing of files without newline at the end of file ending with comment (#237)
13+
- Fixed linter support for docstrings (#233)
1314

1415
## [4.1.0] 2023-07-06
1516

gdtoolkit/linter/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
"tools",
6262
"classnames",
6363
"extends",
64+
"docstrings",
6465
"signals",
6566
"enums",
6667
"consts",

gdtoolkit/linter/class_checks.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ def _map_statement_to_section(statement: Statement) -> str:
141141
return "others"
142142
if statement.kind == "static_func_def":
143143
return "others"
144+
if statement.kind == "docstr_stmt":
145+
return "docstrings"
144146
raise NotImplementedError
145147

146148

tests/linter/test_basic_corner_cases.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,8 @@ def test_newlineless_code():
99
code = """func foo():
1010
pass"""
1111
lint_code(code)
12+
13+
14+
def test_docstring():
15+
code = '"""\nhello world!\n"""'
16+
lint_code(code)

tests/linter/test_class_checks.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def test_private_method_call_nok(code):
3636
pass
3737
class_name Foo
3838
extends Node
39+
"docstring"
3940
signal s
4041
enum { A, B, C }
4142
const X = 1
@@ -90,6 +91,9 @@ class X: var x;extends Node
9091
"""static func foo(): pass
9192
var x
9293
""",
94+
"""'docstring'
95+
extends Node
96+
""",
9397
])
9498
def test_class_definitions_order_nok(code):
9599
simple_nok_check(code, 'class-definitions-order')

0 commit comments

Comments
 (0)