From 41fd241166f898bfc3053585b57f067f3ad11a32 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Sat, 17 Dec 2022 05:43:06 -0800 Subject: [PATCH 01/29] work and test class --- pylint/checkers/utils.py | 5 +++-- tests/functional/a/abstract/abstract_method.py | 11 ++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/pylint/checkers/utils.py b/pylint/checkers/utils.py index 68b103b533..0a875fcb20 100644 --- a/pylint/checkers/utils.py +++ b/pylint/checkers/utils.py @@ -1172,8 +1172,9 @@ def class_is_abstract(node: nodes.ClassDef) -> bool: if meta.name == "ABCMeta" and meta.root().name in ABC_MODULES: return True - for ancestor in node.ancestors(): - if ancestor.name == "ABC" and ancestor.root().name in ABC_MODULES: + # As well as directly inherited ABC class + for base in node.bases: + if base.as_string() in ("abc.ABC", "ABC"): # abc.ABC inheritance return True diff --git a/tests/functional/a/abstract/abstract_method.py b/tests/functional/a/abstract/abstract_method.py index 75ffda2209..71b9ff4773 100644 --- a/tests/functional/a/abstract/abstract_method.py +++ b/tests/functional/a/abstract/abstract_method.py @@ -44,7 +44,16 @@ class AbstractD(AbstractB, metaclass=abc.ABCMeta): """ -class Concrete(Abstract): # [abstract-method] +class ConcreteA(AbstractC): + """ + Concrete class. + + Should trigger a warning since this class does + not directly inherit from abc.ABC. + """ + + +class ConcreteB(Abstract): # [abstract-method] """Concrete class""" def aaaa(self): From 218a0a2a7e277069ef9747730bd90ae6e14ceecb Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Sat, 17 Dec 2022 05:50:26 -0800 Subject: [PATCH 02/29] detect attr --- pylint/checkers/utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pylint/checkers/utils.py b/pylint/checkers/utils.py index 0a875fcb20..ac9f3b297b 100644 --- a/pylint/checkers/utils.py +++ b/pylint/checkers/utils.py @@ -1174,7 +1174,8 @@ def class_is_abstract(node: nodes.ClassDef) -> bool: # As well as directly inherited ABC class for base in node.bases: - if base.as_string() in ("abc.ABC", "ABC"): + base_class_name = base.attrname if isinstance(base, astroid.Attribute) else base.as_string() + if base_class_name == "ABC": # abc.ABC inheritance return True From a73b51f8a1b38320c890c42765f4956329f6188c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 17 Dec 2022 13:51:58 +0000 Subject: [PATCH 03/29] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pylint/checkers/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pylint/checkers/utils.py b/pylint/checkers/utils.py index ac9f3b297b..1732f7afd1 100644 --- a/pylint/checkers/utils.py +++ b/pylint/checkers/utils.py @@ -1174,7 +1174,9 @@ def class_is_abstract(node: nodes.ClassDef) -> bool: # As well as directly inherited ABC class for base in node.bases: - base_class_name = base.attrname if isinstance(base, astroid.Attribute) else base.as_string() + base_class_name = ( + base.attrname if isinstance(base, astroid.Attribute) else base.as_string() + ) if base_class_name == "ABC": # abc.ABC inheritance return True From 855c3548e1e1fe6681b1514ed1f7ed9001488e0e Mon Sep 17 00:00:00 2001 From: sshane Date: Sat, 31 Dec 2022 03:17:47 -0800 Subject: [PATCH 04/29] fix with safe_infer :) --- pylint/checkers/utils.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pylint/checkers/utils.py b/pylint/checkers/utils.py index 1732f7afd1..dba8ffd30c 100644 --- a/pylint/checkers/utils.py +++ b/pylint/checkers/utils.py @@ -1174,10 +1174,8 @@ def class_is_abstract(node: nodes.ClassDef) -> bool: # As well as directly inherited ABC class for base in node.bases: - base_class_name = ( - base.attrname if isinstance(base, astroid.Attribute) else base.as_string() - ) - if base_class_name == "ABC": + inferred_base = safe_infer(base) + if inferred_base.name == "abc" and inferred_base.root().name == "ABC": # abc.ABC inheritance return True From 162ca0fccbc3c76911eafa02a9960917fa9cd6ff Mon Sep 17 00:00:00 2001 From: sshane Date: Sat, 31 Dec 2022 03:21:27 -0800 Subject: [PATCH 05/29] check type --- pylint/checkers/utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pylint/checkers/utils.py b/pylint/checkers/utils.py index dba8ffd30c..312584e815 100644 --- a/pylint/checkers/utils.py +++ b/pylint/checkers/utils.py @@ -1175,9 +1175,9 @@ def class_is_abstract(node: nodes.ClassDef) -> bool: # As well as directly inherited ABC class for base in node.bases: inferred_base = safe_infer(base) - if inferred_base.name == "abc" and inferred_base.root().name == "ABC": - # abc.ABC inheritance - return True + if isinstance(inferred_base, nodes.ClassDef): + if inferred_base.name == "abc" and inferred_base.root().name == "ABC": + return True for method in node.methods(): if method.parent.frame(future=True) is node: From c663428b15c5ef960be45946e797ecaa7d40c09b Mon Sep 17 00:00:00 2001 From: sshane Date: Sat, 31 Dec 2022 03:22:18 -0800 Subject: [PATCH 06/29] formatting --- pylint/checkers/utils.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pylint/checkers/utils.py b/pylint/checkers/utils.py index 312584e815..0d3d514542 100644 --- a/pylint/checkers/utils.py +++ b/pylint/checkers/utils.py @@ -1175,9 +1175,12 @@ def class_is_abstract(node: nodes.ClassDef) -> bool: # As well as directly inherited ABC class for base in node.bases: inferred_base = safe_infer(base) - if isinstance(inferred_base, nodes.ClassDef): - if inferred_base.name == "abc" and inferred_base.root().name == "ABC": - return True + if ( + isinstance(inferred_base, nodes.ClassDef) and + inferred_base.name == "abc" and + inferred_base.root().name == "ABC" + ): + return True for method in node.methods(): if method.parent.frame(future=True) is node: From 5457084f661be99d8953d6a918d35e44fe257d1d Mon Sep 17 00:00:00 2001 From: sshane Date: Sat, 31 Dec 2022 03:23:00 -0800 Subject: [PATCH 07/29] order --- pylint/checkers/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pylint/checkers/utils.py b/pylint/checkers/utils.py index 0d3d514542..38cd1483aa 100644 --- a/pylint/checkers/utils.py +++ b/pylint/checkers/utils.py @@ -1177,8 +1177,8 @@ def class_is_abstract(node: nodes.ClassDef) -> bool: inferred_base = safe_infer(base) if ( isinstance(inferred_base, nodes.ClassDef) and - inferred_base.name == "abc" and - inferred_base.root().name == "ABC" + inferred_base.root().name == "ABC" and + inferred_base.name == "abc" ): return True From 34baede75a3f95d8f7c7cc3ea70c6ab5b1630058 Mon Sep 17 00:00:00 2001 From: sshane Date: Sat, 31 Dec 2022 03:24:12 -0800 Subject: [PATCH 08/29] comment --- pylint/checkers/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pylint/checkers/utils.py b/pylint/checkers/utils.py index 38cd1483aa..9f4bbe8842 100644 --- a/pylint/checkers/utils.py +++ b/pylint/checkers/utils.py @@ -1172,7 +1172,7 @@ def class_is_abstract(node: nodes.ClassDef) -> bool: if meta.name == "ABCMeta" and meta.root().name in ABC_MODULES: return True - # As well as directly inherited ABC class + # As well as direct abc.ABC inheritance for base in node.bases: inferred_base = safe_infer(base) if ( From caa5e2758da3a4b8bde377a4afe851c681afa01f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 31 Dec 2022 11:24:57 +0000 Subject: [PATCH 09/29] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pylint/checkers/utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pylint/checkers/utils.py b/pylint/checkers/utils.py index 9f4bbe8842..8bdef4eb62 100644 --- a/pylint/checkers/utils.py +++ b/pylint/checkers/utils.py @@ -1176,9 +1176,9 @@ def class_is_abstract(node: nodes.ClassDef) -> bool: for base in node.bases: inferred_base = safe_infer(base) if ( - isinstance(inferred_base, nodes.ClassDef) and - inferred_base.root().name == "ABC" and - inferred_base.name == "abc" + isinstance(inferred_base, nodes.ClassDef) + and inferred_base.root().name == "ABC" + and inferred_base.name == "abc" ): return True From 927fb2a570a866a8464bdbc7325dca003b87bb6c Mon Sep 17 00:00:00 2001 From: sshane Date: Sat, 31 Dec 2022 03:27:51 -0800 Subject: [PATCH 10/29] comment --- tests/functional/a/abstract/abstract_method.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/a/abstract/abstract_method.py b/tests/functional/a/abstract/abstract_method.py index 71b9ff4773..82b58706c3 100644 --- a/tests/functional/a/abstract/abstract_method.py +++ b/tests/functional/a/abstract/abstract_method.py @@ -49,7 +49,7 @@ class ConcreteA(AbstractC): Concrete class. Should trigger a warning since this class does - not directly inherit from abc.ABC. + not directly inherit from abc.ABC and is incomplete. """ From 6228ea18435315b0b564a101bc269d2aa37f3c98 Mon Sep 17 00:00:00 2001 From: sshane Date: Sat, 31 Dec 2022 16:23:15 -0800 Subject: [PATCH 11/29] update test refs --- .../functional/a/abstract/abstract_method.txt | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/functional/a/abstract/abstract_method.txt b/tests/functional/a/abstract/abstract_method.txt index f2b2b6c74f..6765e6c516 100644 --- a/tests/functional/a/abstract/abstract_method.txt +++ b/tests/functional/a/abstract/abstract_method.txt @@ -1,16 +1,16 @@ -abstract-method:47:0:47:14:Concrete:Method 'bbbb' is abstract in class 'Abstract' but is not overridden in child class 'Concrete':INFERENCE -abstract-method:70:0:70:15:Container:Method '__hash__' is abstract in class 'Structure' but is not overridden in child class 'Container':INFERENCE -abstract-method:70:0:70:15:Container:Method '__iter__' is abstract in class 'Structure' but is not overridden in child class 'Container':INFERENCE -abstract-method:70:0:70:15:Container:Method '__len__' is abstract in class 'Structure' but is not overridden in child class 'Container':INFERENCE -abstract-method:76:0:76:13:Sizable:Method '__contains__' is abstract in class 'Structure' but is not overridden in child class 'Sizable':INFERENCE -abstract-method:76:0:76:13:Sizable:Method '__hash__' is abstract in class 'Structure' but is not overridden in child class 'Sizable':INFERENCE -abstract-method:76:0:76:13:Sizable:Method '__iter__' is abstract in class 'Structure' but is not overridden in child class 'Sizable':INFERENCE -abstract-method:82:0:82:14:Hashable:Method '__contains__' is abstract in class 'Structure' but is not overridden in child class 'Hashable':INFERENCE -abstract-method:82:0:82:14:Hashable:Method '__iter__' is abstract in class 'Structure' but is not overridden in child class 'Hashable':INFERENCE -abstract-method:82:0:82:14:Hashable:Method '__len__' is abstract in class 'Structure' but is not overridden in child class 'Hashable':INFERENCE -abstract-method:87:0:87:14:Iterator:Method '__contains__' is abstract in class 'Structure' but is not overridden in child class 'Iterator':INFERENCE -abstract-method:87:0:87:14:Iterator:Method '__hash__' is abstract in class 'Structure' but is not overridden in child class 'Iterator':INFERENCE -abstract-method:87:0:87:14:Iterator:Method '__len__' is abstract in class 'Structure' but is not overridden in child class 'Iterator':INFERENCE -abstract-method:106:0:106:19:BadComplexMro:Method '__hash__' is abstract in class 'Structure' but is not overridden in child class 'BadComplexMro':INFERENCE -abstract-method:106:0:106:19:BadComplexMro:Method '__len__' is abstract in class 'AbstractSizable' but is not overridden in child class 'BadComplexMro':INFERENCE -abstract-method:106:0:106:19:BadComplexMro:Method 'length' is abstract in class 'AbstractSizable' but is not overridden in child class 'BadComplexMro':INFERENCE +abstract-method:56:0:56:15:ConcreteB:Method 'bbbb' is abstract in class 'Abstract' but is not overridden:UNDEFINED +abstract-method:79:0:79:15:Container:Method '__hash__' is abstract in class 'Structure' but is not overridden:UNDEFINED +abstract-method:79:0:79:15:Container:Method '__iter__' is abstract in class 'Structure' but is not overridden:UNDEFINED +abstract-method:79:0:79:15:Container:Method '__len__' is abstract in class 'Structure' but is not overridden:UNDEFINED +abstract-method:85:0:85:13:Sizable:Method '__contains__' is abstract in class 'Structure' but is not overridden:UNDEFINED +abstract-method:85:0:85:13:Sizable:Method '__hash__' is abstract in class 'Structure' but is not overridden:UNDEFINED +abstract-method:85:0:85:13:Sizable:Method '__iter__' is abstract in class 'Structure' but is not overridden:UNDEFINED +abstract-method:91:0:91:14:Hashable:Method '__contains__' is abstract in class 'Structure' but is not overridden:UNDEFINED +abstract-method:91:0:91:14:Hashable:Method '__iter__' is abstract in class 'Structure' but is not overridden:UNDEFINED +abstract-method:91:0:91:14:Hashable:Method '__len__' is abstract in class 'Structure' but is not overridden:UNDEFINED +abstract-method:96:0:96:14:Iterator:Method '__contains__' is abstract in class 'Structure' but is not overridden:UNDEFINED +abstract-method:96:0:96:14:Iterator:Method '__hash__' is abstract in class 'Structure' but is not overridden:UNDEFINED +abstract-method:96:0:96:14:Iterator:Method '__len__' is abstract in class 'Structure' but is not overridden:UNDEFINED +abstract-method:115:0:115:19:BadComplexMro:Method '__hash__' is abstract in class 'Structure' but is not overridden:UNDEFINED +abstract-method:115:0:115:19:BadComplexMro:Method '__len__' is abstract in class 'AbstractSizable' but is not overridden:UNDEFINED +abstract-method:115:0:115:19:BadComplexMro:Method 'length' is abstract in class 'AbstractSizable' but is not overridden:UNDEFINED From 132f2341753f7bcc881fe94452979187cfd19dca Mon Sep 17 00:00:00 2001 From: sshane Date: Sat, 31 Dec 2022 17:10:45 -0800 Subject: [PATCH 12/29] fix refs --- .../functional/a/abstract/abstract_method.txt | 38 +++++++++++-------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/tests/functional/a/abstract/abstract_method.txt b/tests/functional/a/abstract/abstract_method.txt index 6765e6c516..61137609c3 100644 --- a/tests/functional/a/abstract/abstract_method.txt +++ b/tests/functional/a/abstract/abstract_method.txt @@ -1,16 +1,22 @@ -abstract-method:56:0:56:15:ConcreteB:Method 'bbbb' is abstract in class 'Abstract' but is not overridden:UNDEFINED -abstract-method:79:0:79:15:Container:Method '__hash__' is abstract in class 'Structure' but is not overridden:UNDEFINED -abstract-method:79:0:79:15:Container:Method '__iter__' is abstract in class 'Structure' but is not overridden:UNDEFINED -abstract-method:79:0:79:15:Container:Method '__len__' is abstract in class 'Structure' but is not overridden:UNDEFINED -abstract-method:85:0:85:13:Sizable:Method '__contains__' is abstract in class 'Structure' but is not overridden:UNDEFINED -abstract-method:85:0:85:13:Sizable:Method '__hash__' is abstract in class 'Structure' but is not overridden:UNDEFINED -abstract-method:85:0:85:13:Sizable:Method '__iter__' is abstract in class 'Structure' but is not overridden:UNDEFINED -abstract-method:91:0:91:14:Hashable:Method '__contains__' is abstract in class 'Structure' but is not overridden:UNDEFINED -abstract-method:91:0:91:14:Hashable:Method '__iter__' is abstract in class 'Structure' but is not overridden:UNDEFINED -abstract-method:91:0:91:14:Hashable:Method '__len__' is abstract in class 'Structure' but is not overridden:UNDEFINED -abstract-method:96:0:96:14:Iterator:Method '__contains__' is abstract in class 'Structure' but is not overridden:UNDEFINED -abstract-method:96:0:96:14:Iterator:Method '__hash__' is abstract in class 'Structure' but is not overridden:UNDEFINED -abstract-method:96:0:96:14:Iterator:Method '__len__' is abstract in class 'Structure' but is not overridden:UNDEFINED -abstract-method:115:0:115:19:BadComplexMro:Method '__hash__' is abstract in class 'Structure' but is not overridden:UNDEFINED -abstract-method:115:0:115:19:BadComplexMro:Method '__len__' is abstract in class 'AbstractSizable' but is not overridden:UNDEFINED -abstract-method:115:0:115:19:BadComplexMro:Method 'length' is abstract in class 'AbstractSizable' but is not overridden:UNDEFINED +abstract-method:29:0:29:15:AbstractC:Method 'aaaa' is abstract in class 'Abstract' but is not overridden in child class 'AbstractC':INFERENCE +abstract-method:29:0:29:15:AbstractC:Method 'bbbb' is abstract in class 'Abstract' but is not overridden in child class 'AbstractC':INFERENCE +abstract-method:29:0:29:15:AbstractC:Method 'cccc' is abstract in class 'AbstractB' but is not overridden in child class 'AbstractC':INFERENCE +abstract-method:47:0:47:15:ConcreteA:Method 'aaaa' is abstract in class 'Abstract' but is not overridden in child class 'ConcreteA':INFERENCE +abstract-method:47:0:47:15:ConcreteA:Method 'bbbb' is abstract in class 'Abstract' but is not overridden in child class 'ConcreteA':INFERENCE +abstract-method:47:0:47:15:ConcreteA:Method 'cccc' is abstract in class 'AbstractB' but is not overridden in child class 'ConcreteA':INFERENCE +abstract-method:56:0:56:15:ConcreteB:Method 'bbbb' is abstract in class 'Abstract' but is not overridden in child class 'ConcreteB':INFERENCE +abstract-method:79:0:79:15:Container:Method '__hash__' is abstract in class 'Structure' but is not overridden in child class 'Container':INFERENCE +abstract-method:79:0:79:15:Container:Method '__iter__' is abstract in class 'Structure' but is not overridden in child class 'Container':INFERENCE +abstract-method:79:0:79:15:Container:Method '__len__' is abstract in class 'Structure' but is not overridden in child class 'Container':INFERENCE +abstract-method:85:0:85:13:Sizable:Method '__contains__' is abstract in class 'Structure' but is not overridden in child class 'Sizable':INFERENCE +abstract-method:85:0:85:13:Sizable:Method '__hash__' is abstract in class 'Structure' but is not overridden in child class 'Sizable':INFERENCE +abstract-method:85:0:85:13:Sizable:Method '__iter__' is abstract in class 'Structure' but is not overridden in child class 'Sizable':INFERENCE +abstract-method:91:0:91:14:Hashable:Method '__contains__' is abstract in class 'Structure' but is not overridden in child class 'Hashable':INFERENCE +abstract-method:91:0:91:14:Hashable:Method '__iter__' is abstract in class 'Structure' but is not overridden in child class 'Hashable':INFERENCE +abstract-method:91:0:91:14:Hashable:Method '__len__' is abstract in class 'Structure' but is not overridden in child class 'Hashable':INFERENCE +abstract-method:96:0:96:14:Iterator:Method '__contains__' is abstract in class 'Structure' but is not overridden in child class 'Iterator':INFERENCE +abstract-method:96:0:96:14:Iterator:Method '__hash__' is abstract in class 'Structure' but is not overridden in child class 'Iterator':INFERENCE +abstract-method:96:0:96:14:Iterator:Method '__len__' is abstract in class 'Structure' but is not overridden in child class 'Iterator':INFERENCE +abstract-method:115:0:115:19:BadComplexMro:Method '__hash__' is abstract in class 'Structure' but is not overridden in child class 'BadComplexMro':INFERENCE +abstract-method:115:0:115:19:BadComplexMro:Method '__len__' is abstract in class 'AbstractSizable' but is not overridden in child class 'BadComplexMro':INFERENCE +abstract-method:115:0:115:19:BadComplexMro:Method 'length' is abstract in class 'AbstractSizable' but is not overridden in child class 'BadComplexMro':INFERENCE From 2d2eea69562e0d1486d66e528faa7c31f665424d Mon Sep 17 00:00:00 2001 From: sshane Date: Sat, 31 Dec 2022 17:17:10 -0800 Subject: [PATCH 13/29] fix detection --- pylint/checkers/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pylint/checkers/utils.py b/pylint/checkers/utils.py index 8bdef4eb62..d93e50f944 100644 --- a/pylint/checkers/utils.py +++ b/pylint/checkers/utils.py @@ -1177,8 +1177,8 @@ def class_is_abstract(node: nodes.ClassDef) -> bool: inferred_base = safe_infer(base) if ( isinstance(inferred_base, nodes.ClassDef) - and inferred_base.root().name == "ABC" - and inferred_base.name == "abc" + and inferred_base.root().name == "abc" + and inferred_base.name == "ABC" ): return True From cadd82e05ef44d83cb59379fad9cb7c9c8e0aa66 Mon Sep 17 00:00:00 2001 From: sshane Date: Sat, 31 Dec 2022 17:19:21 -0800 Subject: [PATCH 14/29] fix refs --- tests/functional/a/abstract/abstract_method.txt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/functional/a/abstract/abstract_method.txt b/tests/functional/a/abstract/abstract_method.txt index 61137609c3..f9a25a7f90 100644 --- a/tests/functional/a/abstract/abstract_method.txt +++ b/tests/functional/a/abstract/abstract_method.txt @@ -1,6 +1,3 @@ -abstract-method:29:0:29:15:AbstractC:Method 'aaaa' is abstract in class 'Abstract' but is not overridden in child class 'AbstractC':INFERENCE -abstract-method:29:0:29:15:AbstractC:Method 'bbbb' is abstract in class 'Abstract' but is not overridden in child class 'AbstractC':INFERENCE -abstract-method:29:0:29:15:AbstractC:Method 'cccc' is abstract in class 'AbstractB' but is not overridden in child class 'AbstractC':INFERENCE abstract-method:47:0:47:15:ConcreteA:Method 'aaaa' is abstract in class 'Abstract' but is not overridden in child class 'ConcreteA':INFERENCE abstract-method:47:0:47:15:ConcreteA:Method 'bbbb' is abstract in class 'Abstract' but is not overridden in child class 'ConcreteA':INFERENCE abstract-method:47:0:47:15:ConcreteA:Method 'cccc' is abstract in class 'AbstractB' but is not overridden in child class 'ConcreteA':INFERENCE @@ -19,4 +16,4 @@ abstract-method:96:0:96:14:Iterator:Method '__hash__' is abstract in class 'Stru abstract-method:96:0:96:14:Iterator:Method '__len__' is abstract in class 'Structure' but is not overridden in child class 'Iterator':INFERENCE abstract-method:115:0:115:19:BadComplexMro:Method '__hash__' is abstract in class 'Structure' but is not overridden in child class 'BadComplexMro':INFERENCE abstract-method:115:0:115:19:BadComplexMro:Method '__len__' is abstract in class 'AbstractSizable' but is not overridden in child class 'BadComplexMro':INFERENCE -abstract-method:115:0:115:19:BadComplexMro:Method 'length' is abstract in class 'AbstractSizable' but is not overridden in child class 'BadComplexMro':INFERENCE +abstract-method:115:0:115:19:BadComplexMro:Method 'length' is abstract in class 'AbstractSizable' but is not overridden in child class 'BadComplexMro':INFERENCE \ No newline at end of file From afd95008f23090aeaf65ac3a703da8c1853b68e8 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 1 Jan 2023 01:20:31 +0000 Subject: [PATCH 15/29] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/functional/a/abstract/abstract_method.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/a/abstract/abstract_method.txt b/tests/functional/a/abstract/abstract_method.txt index f9a25a7f90..3284310137 100644 --- a/tests/functional/a/abstract/abstract_method.txt +++ b/tests/functional/a/abstract/abstract_method.txt @@ -16,4 +16,4 @@ abstract-method:96:0:96:14:Iterator:Method '__hash__' is abstract in class 'Stru abstract-method:96:0:96:14:Iterator:Method '__len__' is abstract in class 'Structure' but is not overridden in child class 'Iterator':INFERENCE abstract-method:115:0:115:19:BadComplexMro:Method '__hash__' is abstract in class 'Structure' but is not overridden in child class 'BadComplexMro':INFERENCE abstract-method:115:0:115:19:BadComplexMro:Method '__len__' is abstract in class 'AbstractSizable' but is not overridden in child class 'BadComplexMro':INFERENCE -abstract-method:115:0:115:19:BadComplexMro:Method 'length' is abstract in class 'AbstractSizable' but is not overridden in child class 'BadComplexMro':INFERENCE \ No newline at end of file +abstract-method:115:0:115:19:BadComplexMro:Method 'length' is abstract in class 'AbstractSizable' but is not overridden in child class 'BadComplexMro':INFERENCE From 5519084af50da4d96a8b9dae918831389661d1db Mon Sep 17 00:00:00 2001 From: sshane Date: Sat, 31 Dec 2022 17:41:19 -0800 Subject: [PATCH 16/29] same check as before --- pylint/checkers/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pylint/checkers/utils.py b/pylint/checkers/utils.py index d93e50f944..71bcf54534 100644 --- a/pylint/checkers/utils.py +++ b/pylint/checkers/utils.py @@ -1177,7 +1177,7 @@ def class_is_abstract(node: nodes.ClassDef) -> bool: inferred_base = safe_infer(base) if ( isinstance(inferred_base, nodes.ClassDef) - and inferred_base.root().name == "abc" + and inferred_base.root().name in ABC_MODULES and inferred_base.name == "ABC" ): return True From bf1b8f67858fcf4b1c9bef06090ca33dbd3b9d73 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Mon, 2 Jan 2023 03:28:25 -0800 Subject: [PATCH 17/29] Update tests/functional/a/abstract/abstract_method.py --- tests/functional/a/abstract/abstract_method.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/a/abstract/abstract_method.py b/tests/functional/a/abstract/abstract_method.py index 82b58706c3..09c1ca6234 100644 --- a/tests/functional/a/abstract/abstract_method.py +++ b/tests/functional/a/abstract/abstract_method.py @@ -44,7 +44,7 @@ class AbstractD(AbstractB, metaclass=abc.ABCMeta): """ -class ConcreteA(AbstractC): +class ConcreteA(AbstractC): # [abstract-method] """ Concrete class. From a62b2e5d1bd412e31c3e7603c736329d846d1d5b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 2 Jan 2023 11:29:26 +0000 Subject: [PATCH 18/29] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/functional/a/abstract/abstract_method.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/a/abstract/abstract_method.py b/tests/functional/a/abstract/abstract_method.py index 09c1ca6234..96c5c9d806 100644 --- a/tests/functional/a/abstract/abstract_method.py +++ b/tests/functional/a/abstract/abstract_method.py @@ -44,7 +44,7 @@ class AbstractD(AbstractB, metaclass=abc.ABCMeta): """ -class ConcreteA(AbstractC): # [abstract-method] +class ConcreteA(AbstractC): # [abstract-method] """ Concrete class. From c8564bb99a393621341851acaa3ed042b3c53c3d Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Tue, 10 Jan 2023 23:05:15 -0800 Subject: [PATCH 19/29] update refs --- tests/functional/c/ctor_arguments.txt | 2 +- tests/functional/u/used/used_before_assignment_ternary.txt | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/functional/c/ctor_arguments.txt b/tests/functional/c/ctor_arguments.txt index f096eed4ea..17491a9585 100644 --- a/tests/functional/c/ctor_arguments.txt +++ b/tests/functional/c/ctor_arguments.txt @@ -15,7 +15,7 @@ too-many-function-args:60:0:60:30::Too many positional arguments for constructor too-many-function-args:63:0:63:17::Too many positional arguments for constructor call:UNDEFINED no-value-for-parameter:64:0:64:15::No value for argument 'first_argument' in constructor call:UNDEFINED unexpected-keyword-arg:64:0:64:15::Unexpected keyword argument 'one' in constructor call:UNDEFINED -line-too-long:85:0::::Line too long (122/100):UNDEFINED +line-too-long:85:0:None:None::Line too long (122/100):UNDEFINED pointless-exception-statement:85:0:85:28::Exception statement has no effect:INFERENCE too-many-function-args:85:0:85:28::Too many positional arguments for constructor call:UNDEFINED unexpected-keyword-arg:85:0:85:28::Unexpected keyword argument 'badarg' in constructor call:UNDEFINED diff --git a/tests/functional/u/used/used_before_assignment_ternary.txt b/tests/functional/u/used/used_before_assignment_ternary.txt index d991970e4c..bcb21df1cb 100644 --- a/tests/functional/u/used/used_before_assignment_ternary.txt +++ b/tests/functional/u/used/used_before_assignment_ternary.txt @@ -1,3 +1,3 @@ -used-before-assignment:6:14:6:15:invalid:Using variable 'a' before assignment:HIGH -used-before-assignment:8:14:8:15:invalid:Using variable 'b' before assignment:HIGH -used-before-assignment:9:10:9:11:invalid:Using variable 'c' before assignment:HIGH +used-before-assignment:6:14:6:15:invalid:Using variable 'a' before assignment:HIGH +used-before-assignment:8:14:8:15:invalid:Using variable 'b' before assignment:HIGH +used-before-assignment:9:10:9:11:invalid:Using variable 'c' before assignment:HIGH From 476e5a56e758e9b0f56c82857fc4e94feeec998e Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Mon, 3 Jun 2024 14:11:19 -0700 Subject: [PATCH 20/29] revert tests for retry --- .../functional/a/abstract/abstract_method.py | 11 +----- .../functional/a/abstract/abstract_method.txt | 35 +++++++++---------- 2 files changed, 17 insertions(+), 29 deletions(-) diff --git a/tests/functional/a/abstract/abstract_method.py b/tests/functional/a/abstract/abstract_method.py index 96c5c9d806..75ffda2209 100644 --- a/tests/functional/a/abstract/abstract_method.py +++ b/tests/functional/a/abstract/abstract_method.py @@ -44,16 +44,7 @@ class AbstractD(AbstractB, metaclass=abc.ABCMeta): """ -class ConcreteA(AbstractC): # [abstract-method] - """ - Concrete class. - - Should trigger a warning since this class does - not directly inherit from abc.ABC and is incomplete. - """ - - -class ConcreteB(Abstract): # [abstract-method] +class Concrete(Abstract): # [abstract-method] """Concrete class""" def aaaa(self): diff --git a/tests/functional/a/abstract/abstract_method.txt b/tests/functional/a/abstract/abstract_method.txt index 3284310137..f2b2b6c74f 100644 --- a/tests/functional/a/abstract/abstract_method.txt +++ b/tests/functional/a/abstract/abstract_method.txt @@ -1,19 +1,16 @@ -abstract-method:47:0:47:15:ConcreteA:Method 'aaaa' is abstract in class 'Abstract' but is not overridden in child class 'ConcreteA':INFERENCE -abstract-method:47:0:47:15:ConcreteA:Method 'bbbb' is abstract in class 'Abstract' but is not overridden in child class 'ConcreteA':INFERENCE -abstract-method:47:0:47:15:ConcreteA:Method 'cccc' is abstract in class 'AbstractB' but is not overridden in child class 'ConcreteA':INFERENCE -abstract-method:56:0:56:15:ConcreteB:Method 'bbbb' is abstract in class 'Abstract' but is not overridden in child class 'ConcreteB':INFERENCE -abstract-method:79:0:79:15:Container:Method '__hash__' is abstract in class 'Structure' but is not overridden in child class 'Container':INFERENCE -abstract-method:79:0:79:15:Container:Method '__iter__' is abstract in class 'Structure' but is not overridden in child class 'Container':INFERENCE -abstract-method:79:0:79:15:Container:Method '__len__' is abstract in class 'Structure' but is not overridden in child class 'Container':INFERENCE -abstract-method:85:0:85:13:Sizable:Method '__contains__' is abstract in class 'Structure' but is not overridden in child class 'Sizable':INFERENCE -abstract-method:85:0:85:13:Sizable:Method '__hash__' is abstract in class 'Structure' but is not overridden in child class 'Sizable':INFERENCE -abstract-method:85:0:85:13:Sizable:Method '__iter__' is abstract in class 'Structure' but is not overridden in child class 'Sizable':INFERENCE -abstract-method:91:0:91:14:Hashable:Method '__contains__' is abstract in class 'Structure' but is not overridden in child class 'Hashable':INFERENCE -abstract-method:91:0:91:14:Hashable:Method '__iter__' is abstract in class 'Structure' but is not overridden in child class 'Hashable':INFERENCE -abstract-method:91:0:91:14:Hashable:Method '__len__' is abstract in class 'Structure' but is not overridden in child class 'Hashable':INFERENCE -abstract-method:96:0:96:14:Iterator:Method '__contains__' is abstract in class 'Structure' but is not overridden in child class 'Iterator':INFERENCE -abstract-method:96:0:96:14:Iterator:Method '__hash__' is abstract in class 'Structure' but is not overridden in child class 'Iterator':INFERENCE -abstract-method:96:0:96:14:Iterator:Method '__len__' is abstract in class 'Structure' but is not overridden in child class 'Iterator':INFERENCE -abstract-method:115:0:115:19:BadComplexMro:Method '__hash__' is abstract in class 'Structure' but is not overridden in child class 'BadComplexMro':INFERENCE -abstract-method:115:0:115:19:BadComplexMro:Method '__len__' is abstract in class 'AbstractSizable' but is not overridden in child class 'BadComplexMro':INFERENCE -abstract-method:115:0:115:19:BadComplexMro:Method 'length' is abstract in class 'AbstractSizable' but is not overridden in child class 'BadComplexMro':INFERENCE +abstract-method:47:0:47:14:Concrete:Method 'bbbb' is abstract in class 'Abstract' but is not overridden in child class 'Concrete':INFERENCE +abstract-method:70:0:70:15:Container:Method '__hash__' is abstract in class 'Structure' but is not overridden in child class 'Container':INFERENCE +abstract-method:70:0:70:15:Container:Method '__iter__' is abstract in class 'Structure' but is not overridden in child class 'Container':INFERENCE +abstract-method:70:0:70:15:Container:Method '__len__' is abstract in class 'Structure' but is not overridden in child class 'Container':INFERENCE +abstract-method:76:0:76:13:Sizable:Method '__contains__' is abstract in class 'Structure' but is not overridden in child class 'Sizable':INFERENCE +abstract-method:76:0:76:13:Sizable:Method '__hash__' is abstract in class 'Structure' but is not overridden in child class 'Sizable':INFERENCE +abstract-method:76:0:76:13:Sizable:Method '__iter__' is abstract in class 'Structure' but is not overridden in child class 'Sizable':INFERENCE +abstract-method:82:0:82:14:Hashable:Method '__contains__' is abstract in class 'Structure' but is not overridden in child class 'Hashable':INFERENCE +abstract-method:82:0:82:14:Hashable:Method '__iter__' is abstract in class 'Structure' but is not overridden in child class 'Hashable':INFERENCE +abstract-method:82:0:82:14:Hashable:Method '__len__' is abstract in class 'Structure' but is not overridden in child class 'Hashable':INFERENCE +abstract-method:87:0:87:14:Iterator:Method '__contains__' is abstract in class 'Structure' but is not overridden in child class 'Iterator':INFERENCE +abstract-method:87:0:87:14:Iterator:Method '__hash__' is abstract in class 'Structure' but is not overridden in child class 'Iterator':INFERENCE +abstract-method:87:0:87:14:Iterator:Method '__len__' is abstract in class 'Structure' but is not overridden in child class 'Iterator':INFERENCE +abstract-method:106:0:106:19:BadComplexMro:Method '__hash__' is abstract in class 'Structure' but is not overridden in child class 'BadComplexMro':INFERENCE +abstract-method:106:0:106:19:BadComplexMro:Method '__len__' is abstract in class 'AbstractSizable' but is not overridden in child class 'BadComplexMro':INFERENCE +abstract-method:106:0:106:19:BadComplexMro:Method 'length' is abstract in class 'AbstractSizable' but is not overridden in child class 'BadComplexMro':INFERENCE From 6fd65a73e3735ac332ae5574b6f4d954afcb18da Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Mon, 3 Jun 2024 14:30:03 -0700 Subject: [PATCH 21/29] stash --- .../functional/a/abstract/abstract_method.py | 34 +++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/tests/functional/a/abstract/abstract_method.py b/tests/functional/a/abstract/abstract_method.py index 75ffda2209..89613750f4 100644 --- a/tests/functional/a/abstract/abstract_method.py +++ b/tests/functional/a/abstract/abstract_method.py @@ -44,12 +44,42 @@ class AbstractD(AbstractB, metaclass=abc.ABCMeta): """ -class Concrete(Abstract): # [abstract-method] - """Concrete class""" +class ConcreteA(AbstractC): # [abstract-method] + """ + Incomplete concrete class. + + Should trigger a warning for unimplemented abstract + methods while not directly inheriting from abc.ABC. + """ + + +class ConcreteB(Abstract): # [abstract-method] + """ + Incomplete concrete class. + + Should trigger a warning for unimplemented abstract + methods while not directly inheriting from abc.ABC. + """ + + def aaaa(self): + """overridden form Abstract""" + +class ConcreteC(AbstractC): + """ + Complete concrete class + + Should not trigger a warning as all abstract methods are implemented. + """ def aaaa(self): """overridden form Abstract""" + def bbbb(self): + """overridden form Abstract""" + + def cccc(self): + """overridden form AbstractB""" + class Structure(metaclass=abc.ABCMeta): @abc.abstractmethod From 9582aa06f5f62eb1aee791df0e22d0b5f9736fd3 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Mon, 3 Jun 2024 14:57:22 -0700 Subject: [PATCH 22/29] fix tests --- tests/functional/a/abstract/abstract_method.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/functional/a/abstract/abstract_method.py b/tests/functional/a/abstract/abstract_method.py index 89613750f4..d54fb7adf4 100644 --- a/tests/functional/a/abstract/abstract_method.py +++ b/tests/functional/a/abstract/abstract_method.py @@ -6,7 +6,7 @@ import abc -class Abstract: +class Abstract(abc.ABC): def aaaa(self): """should be overridden in concrete class""" raise NotImplementedError() @@ -16,7 +16,7 @@ def bbbb(self): raise NotImplementedError() -class AbstractB(Abstract): +class AbstractB(Abstract, abc.ABC): """Abstract class. this class is checking that it does not output an error msg for @@ -49,7 +49,7 @@ class ConcreteA(AbstractC): # [abstract-method] Incomplete concrete class. Should trigger a warning for unimplemented abstract - methods while not directly inheriting from abc.ABC. + methods, for lack of explicit abc.ABC inheritance. """ @@ -58,7 +58,7 @@ class ConcreteB(Abstract): # [abstract-method] Incomplete concrete class. Should trigger a warning for unimplemented abstract - methods while not directly inheriting from abc.ABC. + methods, for lack of explicit abc.ABC inheritance. """ def aaaa(self): @@ -69,7 +69,8 @@ class ConcreteC(AbstractC): """ Complete concrete class - Should not trigger a warning as all abstract methods are implemented. + Should not trigger a warning as all + abstract methods are implemented. """ def aaaa(self): """overridden form Abstract""" From 38d3383cb4881e90d5470ffcb2df9d005746fd33 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Mon, 3 Jun 2024 15:32:19 -0700 Subject: [PATCH 23/29] check text first --- pylint/testutils/lint_module_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pylint/testutils/lint_module_test.py b/pylint/testutils/lint_module_test.py index 48ee5a0b2f..9d76f76d69 100644 --- a/pylint/testutils/lint_module_test.py +++ b/pylint/testutils/lint_module_test.py @@ -253,12 +253,12 @@ def _runTest(self) -> None: self._linter.check(modules_to_check) expected_messages, expected_output = self._get_expected() actual_messages, actual_output = self._get_actual() + self._check_output_text(expected_messages, expected_output, actual_output) assert ( expected_messages == actual_messages ), self.error_msg_for_unequal_messages( actual_messages, expected_messages, actual_output ) - self._check_output_text(expected_messages, expected_output, actual_output) def error_msg_for_unequal_messages( self, From 4398445e3248ae7e21040689b965db23af297c8d Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Mon, 3 Jun 2024 15:39:27 -0700 Subject: [PATCH 24/29] still doesn't pass? --- .../functional/a/abstract/abstract_method.txt | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/tests/functional/a/abstract/abstract_method.txt b/tests/functional/a/abstract/abstract_method.txt index f2b2b6c74f..8ee1ffd6cf 100644 --- a/tests/functional/a/abstract/abstract_method.txt +++ b/tests/functional/a/abstract/abstract_method.txt @@ -1,16 +1,19 @@ -abstract-method:47:0:47:14:Concrete:Method 'bbbb' is abstract in class 'Abstract' but is not overridden in child class 'Concrete':INFERENCE -abstract-method:70:0:70:15:Container:Method '__hash__' is abstract in class 'Structure' but is not overridden in child class 'Container':INFERENCE -abstract-method:70:0:70:15:Container:Method '__iter__' is abstract in class 'Structure' but is not overridden in child class 'Container':INFERENCE -abstract-method:70:0:70:15:Container:Method '__len__' is abstract in class 'Structure' but is not overridden in child class 'Container':INFERENCE -abstract-method:76:0:76:13:Sizable:Method '__contains__' is abstract in class 'Structure' but is not overridden in child class 'Sizable':INFERENCE -abstract-method:76:0:76:13:Sizable:Method '__hash__' is abstract in class 'Structure' but is not overridden in child class 'Sizable':INFERENCE -abstract-method:76:0:76:13:Sizable:Method '__iter__' is abstract in class 'Structure' but is not overridden in child class 'Sizable':INFERENCE -abstract-method:82:0:82:14:Hashable:Method '__contains__' is abstract in class 'Structure' but is not overridden in child class 'Hashable':INFERENCE -abstract-method:82:0:82:14:Hashable:Method '__iter__' is abstract in class 'Structure' but is not overridden in child class 'Hashable':INFERENCE -abstract-method:82:0:82:14:Hashable:Method '__len__' is abstract in class 'Structure' but is not overridden in child class 'Hashable':INFERENCE -abstract-method:87:0:87:14:Iterator:Method '__contains__' is abstract in class 'Structure' but is not overridden in child class 'Iterator':INFERENCE -abstract-method:87:0:87:14:Iterator:Method '__hash__' is abstract in class 'Structure' but is not overridden in child class 'Iterator':INFERENCE -abstract-method:87:0:87:14:Iterator:Method '__len__' is abstract in class 'Structure' but is not overridden in child class 'Iterator':INFERENCE -abstract-method:106:0:106:19:BadComplexMro:Method '__hash__' is abstract in class 'Structure' but is not overridden in child class 'BadComplexMro':INFERENCE -abstract-method:106:0:106:19:BadComplexMro:Method '__len__' is abstract in class 'AbstractSizable' but is not overridden in child class 'BadComplexMro':INFERENCE -abstract-method:106:0:106:19:BadComplexMro:Method 'length' is abstract in class 'AbstractSizable' but is not overridden in child class 'BadComplexMro':INFERENCE +abstract-method:47:0:47:15:ConcreteA:Method 'aaaa' is abstract in class 'Abstract' but is not overridden in child class 'ConcreteA':INFERENCE +abstract-method:47:0:47:15:ConcreteA:Method 'bbbb' is abstract in class 'Abstract' but is not overridden in child class 'ConcreteA':INFERENCE +abstract-method:47:0:47:15:ConcreteA:Method 'cccc' is abstract in class 'AbstractB' but is not overridden in child class 'ConcreteA':INFERENCE +abstract-method:56:0:56:15:ConcreteB:Method 'bbbb' is abstract in class 'Abstract' but is not overridden in child class 'ConcreteB':INFERENCE +abstract-method:101:0:101:15:Container:Method '__hash__' is abstract in class 'Structure' but is not overridden in child class 'Container':INFERENCE +abstract-method:101:0:101:15:Container:Method '__iter__' is abstract in class 'Structure' but is not overridden in child class 'Container':INFERENCE +abstract-method:101:0:101:15:Container:Method '__len__' is abstract in class 'Structure' but is not overridden in child class 'Container':INFERENCE +abstract-method:107:0:107:13:Sizable:Method '__contains__' is abstract in class 'Structure' but is not overridden in child class 'Sizable':INFERENCE +abstract-method:107:0:107:13:Sizable:Method '__hash__' is abstract in class 'Structure' but is not overridden in child class 'Sizable':INFERENCE +abstract-method:107:0:107:13:Sizable:Method '__iter__' is abstract in class 'Structure' but is not overridden in child class 'Sizable':INFERENCE +abstract-method:113:0:113:14:Hashable:Method '__contains__' is abstract in class 'Structure' but is not overridden in child class 'Hashable':INFERENCE +abstract-method:113:0:113:14:Hashable:Method '__iter__' is abstract in class 'Structure' but is not overridden in child class 'Hashable':INFERENCE +abstract-method:113:0:113:14:Hashable:Method '__len__' is abstract in class 'Structure' but is not overridden in child class 'Hashable':INFERENCE +abstract-method:118:0:118:14:Iterator:Method '__contains__' is abstract in class 'Structure' but is not overridden in child class 'Iterator':INFERENCE +abstract-method:118:0:118:14:Iterator:Method '__hash__' is abstract in class 'Structure' but is not overridden in child class 'Iterator':INFERENCE +abstract-method:118:0:118:14:Iterator:Method '__len__' is abstract in class 'Structure' but is not overridden in child class 'Iterator':INFERENCE +abstract-method:137:0:137:19:BadComplexMro:Method '__hash__' is abstract in class 'Structure' but is not overridden in child class 'BadComplexMro':INFERENCE +abstract-method:137:0:137:19:BadComplexMro:Method '__len__' is abstract in class 'AbstractSizable' but is not overridden in child class 'BadComplexMro':INFERENCE +abstract-method:137:0:137:19:BadComplexMro:Method 'length' is abstract in class 'AbstractSizable' but is not overridden in child class 'BadComplexMro':INFERENCE From 591d1abe31a2fe41c69c104a161c5a721413d8a6 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Tue, 4 Jun 2024 00:02:42 -0700 Subject: [PATCH 25/29] ugh --- tests/functional/a/abstract/abstract_method.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/a/abstract/abstract_method.py b/tests/functional/a/abstract/abstract_method.py index d54fb7adf4..04d91dbc91 100644 --- a/tests/functional/a/abstract/abstract_method.py +++ b/tests/functional/a/abstract/abstract_method.py @@ -44,7 +44,7 @@ class AbstractD(AbstractB, metaclass=abc.ABCMeta): """ -class ConcreteA(AbstractC): # [abstract-method] +class ConcreteA(AbstractC): # [abstract-method, abstract-method, abstract-method] """ Incomplete concrete class. From 686977ab46b130d028e823b77c44cf76fbda9c76 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Tue, 4 Jun 2024 00:03:37 -0700 Subject: [PATCH 26/29] fix comments --- tests/functional/a/abstract/abstract_method.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/functional/a/abstract/abstract_method.py b/tests/functional/a/abstract/abstract_method.py index 04d91dbc91..3e0c518e5c 100644 --- a/tests/functional/a/abstract/abstract_method.py +++ b/tests/functional/a/abstract/abstract_method.py @@ -49,7 +49,7 @@ class ConcreteA(AbstractC): # [abstract-method, abstract-method, abstract-metho Incomplete concrete class. Should trigger a warning for unimplemented abstract - methods, for lack of explicit abc.ABC inheritance. + methods due to lack of explicit abc.ABC inheritance. """ @@ -58,7 +58,7 @@ class ConcreteB(Abstract): # [abstract-method] Incomplete concrete class. Should trigger a warning for unimplemented abstract - methods, for lack of explicit abc.ABC inheritance. + methods due to lack of explicit abc.ABC inheritance. """ def aaaa(self): From 5ff5496ce06e13538356b9d0ade56de47b5325f1 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Tue, 4 Jun 2024 00:08:55 -0700 Subject: [PATCH 27/29] other PR --- pylint/testutils/lint_module_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pylint/testutils/lint_module_test.py b/pylint/testutils/lint_module_test.py index 9d76f76d69..48ee5a0b2f 100644 --- a/pylint/testutils/lint_module_test.py +++ b/pylint/testutils/lint_module_test.py @@ -253,12 +253,12 @@ def _runTest(self) -> None: self._linter.check(modules_to_check) expected_messages, expected_output = self._get_expected() actual_messages, actual_output = self._get_actual() - self._check_output_text(expected_messages, expected_output, actual_output) assert ( expected_messages == actual_messages ), self.error_msg_for_unequal_messages( actual_messages, expected_messages, actual_output ) + self._check_output_text(expected_messages, expected_output, actual_output) def error_msg_for_unequal_messages( self, From f2fd7a07578f88ebacb20c5f99fe28660f63825d Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Tue, 4 Jun 2024 00:53:05 -0700 Subject: [PATCH 28/29] add count --- pylint/testutils/lint_module_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pylint/testutils/lint_module_test.py b/pylint/testutils/lint_module_test.py index 48ee5a0b2f..5e0465a218 100644 --- a/pylint/testutils/lint_module_test.py +++ b/pylint/testutils/lint_module_test.py @@ -272,10 +272,10 @@ def error_msg_for_unequal_messages( ) if missing: msg.append("\nExpected in testdata:") - msg.extend(f" {msg[0]:3}: {msg[1]}" for msg in sorted(missing)) + msg.extend(f" {msg[0]:3}: {msg[1]} ({cnt})" for msg, cnt in sorted(missing.items())) if unexpected: msg.append("\nUnexpected in testdata:") - msg.extend(f" {msg[0]:3}: {msg[1]}" for msg in sorted(unexpected)) + msg.extend(f" {msg[0]:3}: {msg[1]} ({cnt})" for msg, cnt in sorted(unexpected.items())) error_msg = "\n".join(msg) if self._config and self._config.getoption("verbose") > 0: error_msg += "\n\nActual pylint output for this file:\n" From 334651c993ab1bc3376af45ca8a1a34ec7c948c6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 4 Jun 2024 07:54:58 +0000 Subject: [PATCH 29/29] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pylint/testutils/lint_module_test.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pylint/testutils/lint_module_test.py b/pylint/testutils/lint_module_test.py index 5e0465a218..6930c4fd3d 100644 --- a/pylint/testutils/lint_module_test.py +++ b/pylint/testutils/lint_module_test.py @@ -272,10 +272,15 @@ def error_msg_for_unequal_messages( ) if missing: msg.append("\nExpected in testdata:") - msg.extend(f" {msg[0]:3}: {msg[1]} ({cnt})" for msg, cnt in sorted(missing.items())) + msg.extend( + f" {msg[0]:3}: {msg[1]} ({cnt})" for msg, cnt in sorted(missing.items()) + ) if unexpected: msg.append("\nUnexpected in testdata:") - msg.extend(f" {msg[0]:3}: {msg[1]} ({cnt})" for msg, cnt in sorted(unexpected.items())) + msg.extend( + f" {msg[0]:3}: {msg[1]} ({cnt})" + for msg, cnt in sorted(unexpected.items()) + ) error_msg = "\n".join(msg) if self._config and self._config.getoption("verbose") > 0: error_msg += "\n\nActual pylint output for this file:\n"