Skip to content

Commit fcd3067

Browse files
committed
Remove 'private-method-call' linter check, fixes #308
1 parent b696bd0 commit fcd3067

File tree

4 files changed

+8
-69
lines changed

4 files changed

+8
-69
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## [master]
4+
5+
### Changed
6+
- Removed `private-method-call` linter check due to false positives when calling `super._foo()`
7+
38
## [4.3.1] 2024-08-24
49

510
### Added

gdtoolkit/linter/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
# unreachable # check in godot
5757
# using-constant-test # check in godot
5858
# class checks
59-
"private-method-call": None,
6059
"class-definitions-order": [
6160
"tools",
6261
"classnames",

gdtoolkit/linter/class_checks.py

Lines changed: 3 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from functools import partial
22
from types import MappingProxyType
3-
from typing import Callable, List, Tuple
3+
from typing import List
44

5-
from lark import Token, Tree
5+
from lark import Tree
66

77
from ..common.ast import AbstractSyntaxTree, Class, Statement, Annotation
88
from ..common.utils import find_name_token_among_children, get_line, get_column
@@ -13,17 +13,6 @@
1313

1414
def lint(parse_tree: Tree, config: MappingProxyType) -> List[Problem]:
1515
disable = config["disable"]
16-
checks_to_run_w_tree = [
17-
(
18-
"private-method-call",
19-
_private_method_call_check,
20-
),
21-
] # type: List[Tuple[str, Callable]]
22-
problem_clusters = (
23-
function(parse_tree) if name not in disable else []
24-
for name, function in checks_to_run_w_tree
25-
)
26-
problems = [problem for cluster in problem_clusters for problem in cluster]
2716
checks_to_run_w_ast = [
2817
(
2918
"class-definitions-order",
@@ -35,34 +24,7 @@ def lint(parse_tree: Tree, config: MappingProxyType) -> List[Problem]:
3524
function(ast) if name not in disable else []
3625
for name, function in checks_to_run_w_ast
3726
)
38-
problems += [problem for cluster in problem_clusters for problem in cluster]
39-
return problems
40-
41-
42-
def _private_method_call_check(parse_tree: Tree) -> List[Problem]:
43-
problems = []
44-
for getattr_call in parse_tree.find_data("getattr_call"):
45-
_getattr = getattr_call.children[0]
46-
callee_name_token = _getattr.children[-1]
47-
callee_name = callee_name_token.value
48-
called = _getattr.children[-3]
49-
if (
50-
isinstance(called, Token)
51-
and called.type == "NAME"
52-
and called.value == "self"
53-
):
54-
continue
55-
if is_function_public(callee_name):
56-
continue
57-
problems.append(
58-
Problem(
59-
name="private-method-call",
60-
description='Private method "{}" has been called'.format(callee_name),
61-
line=get_line(callee_name_token),
62-
column=get_column(callee_name_token),
63-
)
64-
)
65-
return problems
27+
return [problem for cluster in problem_clusters for problem in cluster]
6628

6729

6830
def _class_definitions_order_check(

tests/linter/test_class_checks.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,6 @@
44

55

66
# fmt: off
7-
@pytest.mark.parametrize('code', [
8-
"""
9-
var x = _foo()
10-
""",
11-
"""
12-
var x = self._foo()
13-
""",
14-
"""
15-
var x = a.b.c.foo()
16-
""",
17-
])
18-
def test_private_method_call_ok(code):
19-
simple_ok_check(code)
20-
21-
22-
@pytest.mark.parametrize('code', [
23-
"""
24-
var x = y._foo()
25-
""",
26-
"""
27-
var x = a.b.c._foo()
28-
""",
29-
])
30-
def test_private_method_call_nok(code):
31-
simple_nok_check(code, 'private-method-call')
32-
33-
347
@pytest.mark.parametrize('code', [
358
"""
369
pass

0 commit comments

Comments
 (0)