summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2018-09-15 10:35:54 +0200
committerClaudiu Popa <pcmanticore@gmail.com>2018-09-15 10:35:54 +0200
commitc8e0992d31b831b7d60b1e8582b84068d50c3afd (patch)
treee26c9bc74a82b7bffb34502b5843b97aaf5dec69
parent2810cca9c2f233fbb4b4c7ecba4af1b70d151ca1 (diff)
downloadpylint-git-c8e0992d31b831b7d60b1e8582b84068d50c3afd.tar.gz
```too-few-public-methods`` is not reported for dataclasses created with options.
Close #2488
-rw-r--r--ChangeLog4
-rw-r--r--pylint/checkers/utils.py6
-rw-r--r--pylint/test/functional/too_few_public_methods_37.py5
3 files changed, 14 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index fdbedcbd5..0e558d541 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,10 @@ What's New in Pylint 2.2?
Release date: TBA
+ * ```too-few-public-methods`` is not reported for dataclasses created with options.
+
+ Close #2488
+
* Remove wrong modules from 'bad-python3-import'.
Close #2453
diff --git a/pylint/checkers/utils.py b/pylint/checkers/utils.py
index 4c163df58..e0b36bb7b 100644
--- a/pylint/checkers/utils.py
+++ b/pylint/checkers/utils.py
@@ -1014,14 +1014,18 @@ def is_dataclass(node: astroid.ClassDef) -> bool:
"""
if not node.decorators:
return False
+
+ root_locals = node.root().locals
for decorator in node.decorators.nodes:
+ if isinstance(decorator, astroid.Call):
+ decorator = decorator.func
if not isinstance(decorator, (astroid.Name, astroid.Attribute)):
continue
if isinstance(decorator, astroid.Name):
name = decorator.name
else:
name = decorator.attrname
- if name == DATACLASS_DECORATOR and DATACLASS_DECORATOR in node.root().locals:
+ if name == DATACLASS_DECORATOR and DATACLASS_DECORATOR in root_locals:
return True
return False
diff --git a/pylint/test/functional/too_few_public_methods_37.py b/pylint/test/functional/too_few_public_methods_37.py
index aa57332e1..56b275f73 100644
--- a/pylint/test/functional/too_few_public_methods_37.py
+++ b/pylint/test/functional/too_few_public_methods_37.py
@@ -12,3 +12,8 @@ class ScheduledTxSearchModel:
@dataclass
class ScheduledTxSearchModelOne:
date = None
+
+
+@dataclass(frozen=True)
+class Test:
+ some_integer: int