summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Walls <jacobtylerwalls@gmail.com>2023-04-23 08:35:43 -0400
committerJacob Walls <jacobtylerwalls@gmail.com>2023-04-23 12:43:23 -0400
commit5ddf4a61d211c9db2e49a081fa26562d57313db3 (patch)
tree6df135ed6bafbc608ff5cad21b5a872a881ba4d2
parent3d036b78fca6e80222f9ca2ffd0f25950d261aed (diff)
downloadpylint-git-5ddf4a61d211c9db2e49a081fa26562d57313db3.tar.gz
Cache `class_is_abstract()`
For one project in the pylint primer (music21), provides 15% speedup linting the entire project.
-rw-r--r--pylint/checkers/utils.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/pylint/checkers/utils.py b/pylint/checkers/utils.py
index 38321bc11..c76c767aa 100644
--- a/pylint/checkers/utils.py
+++ b/pylint/checkers/utils.py
@@ -1130,6 +1130,7 @@ def node_ignores_exception(
return any(get_contextlib_suppressors(node, exception))
+@lru_cache(maxsize=1024)
def class_is_abstract(node: nodes.ClassDef) -> bool:
"""Return true if the given class node should be considered as an abstract
class.
@@ -2191,6 +2192,7 @@ def overridden_method(
def clear_lru_caches() -> None:
"""Clear caches holding references to AST nodes."""
caches_holding_node_references: list[_lru_cache_wrapper[Any]] = [
+ class_is_abstract,
in_for_else_branch,
infer_all,
is_overload_stub,