diff options
author | Nick Drozd <nicholasdrozd@gmail.com> | 2022-11-30 14:14:42 -0500 |
---|---|---|
committer | Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com> | 2022-11-30 20:56:48 +0100 |
commit | 8e2c9078922ca1676587a78caa95509a1f8397f5 (patch) | |
tree | 660700f90fd1952d20a6dbb6a0429811d06e0ab9 | |
parent | 85e7d93ebbc47b480f1f32bac44633a2b34fc200 (diff) | |
download | pylint-git-8e2c9078922ca1676587a78caa95509a1f8397f5.tar.gz |
Cut oldstyle checks
-rw-r--r-- | pylint/checkers/classes/class_checker.py | 3 | ||||
-rw-r--r-- | pylint/checkers/typecheck.py | 11 | ||||
-rw-r--r-- | pylint/checkers/utils.py | 7 |
3 files changed, 3 insertions, 18 deletions
diff --git a/pylint/checkers/classes/class_checker.py b/pylint/checkers/classes/class_checker.py index 67acd25af..281eed15f 100644 --- a/pylint/checkers/classes/class_checker.py +++ b/pylint/checkers/classes/class_checker.py @@ -873,9 +873,6 @@ a metaclass class method.", self.add_message("inconsistent-mro", args=node.name, node=node) except astroid.DuplicateBasesError: self.add_message("duplicate-bases", args=node.name, node=node) - except NotImplementedError: - # Old style class, there's no mro so don't do anything. - pass def _check_proper_bases(self, node: nodes.ClassDef) -> None: """Detect that a class inherits something which is not diff --git a/pylint/checkers/typecheck.py b/pylint/checkers/typecheck.py index 192bccbbb..d622b3d57 100644 --- a/pylint/checkers/typecheck.py +++ b/pylint/checkers/typecheck.py @@ -748,15 +748,8 @@ def _no_context_variadic( def _is_invalid_metaclass(metaclass: nodes.ClassDef) -> bool: - try: - mro = metaclass.mro() - except NotImplementedError: - # Cannot have a metaclass which is not a newstyle class. - return True - else: - if not any(is_builtin_object(cls) and cls.name == "type" for cls in mro): - return True - return False + mro = metaclass.mro() + return not any(is_builtin_object(cls) and cls.name == "type" for cls in mro) def _infer_from_metaclass_constructor( diff --git a/pylint/checkers/utils.py b/pylint/checkers/utils.py index 585c3f894..3b94da98e 100644 --- a/pylint/checkers/utils.py +++ b/pylint/checkers/utils.py @@ -950,9 +950,7 @@ def unimplemented_abstract_methods( A method can be considered abstract if the callback *is_abstract_cb* returns a ``True`` value. The check defaults to verifying that a method is decorated with abstract methods. - The function will work only for new-style classes. For old-style - classes, it will simply return an empty dictionary. - For the rest of them, it will return a dictionary of abstract method + It will return a dictionary of abstract method names and their inferred objects. """ if is_abstract_cb is None: @@ -960,9 +958,6 @@ def unimplemented_abstract_methods( visited: dict[str, nodes.FunctionDef] = {} try: mro = reversed(node.mro()) - except NotImplementedError: - # Old style class, it will not have a mro. - return {} except astroid.ResolveError: # Probably inconsistent hierarchy, don't try to figure this out here. return {} |