summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/audit.py3
-rw-r--r--lib/spack/spack/build_environment.py2
-rw-r--r--lib/spack/spack/multimethod.py3
-rw-r--r--lib/spack/spack/package_base.py2
-rw-r--r--lib/spack/spack/patch.py5
-rw-r--r--lib/spack/spack/repo.py2
-rw-r--r--lib/spack/spack/test/build_environment.py3
-rw-r--r--lib/spack/spack/test/spec_syntax.py3
8 files changed, 9 insertions, 14 deletions
diff --git a/lib/spack/spack/audit.py b/lib/spack/spack/audit.py
index e4947f05a0..9ff3e8dd29 100644
--- a/lib/spack/spack/audit.py
+++ b/lib/spack/spack/audit.py
@@ -39,7 +39,6 @@ import ast
import collections
import collections.abc
import glob
-import inspect
import io
import itertools
import os
@@ -525,7 +524,7 @@ def _search_for_reserved_attributes_names_in_packages(pkgs, error_cls):
name_definitions = collections.defaultdict(list)
pkg_cls = spack.repo.PATH.get_pkg_class(pkg_name)
- for cls_item in inspect.getmro(pkg_cls):
+ for cls_item in pkg_cls.__mro__:
for name in RESERVED_NAMES:
current_value = cls_item.__dict__.get(name)
if current_value is None:
diff --git a/lib/spack/spack/build_environment.py b/lib/spack/spack/build_environment.py
index 7b02dbcae2..6e91b17bdc 100644
--- a/lib/spack/spack/build_environment.py
+++ b/lib/spack/spack/build_environment.py
@@ -1559,7 +1559,7 @@ class ModuleChangePropagator:
#: Modules for the classes in the MRO up to PackageBase
modules_in_mro = []
- for cls in inspect.getmro(type(package)):
+ for cls in type(package).__mro__:
module = cls.module
if module == self.current_module:
diff --git a/lib/spack/spack/multimethod.py b/lib/spack/spack/multimethod.py
index b245c6fc1b..7f4fc0d1b0 100644
--- a/lib/spack/spack/multimethod.py
+++ b/lib/spack/spack/multimethod.py
@@ -25,7 +25,6 @@ depending on the scenario, regular old conditionals might be clearer,
so package authors should use their judgement.
"""
import functools
-import inspect
from contextlib import contextmanager
import spack.directives_meta
@@ -133,7 +132,7 @@ class SpecMultiMethod:
# its superclasses for successive calls. We don't have that
# information within `SpecMultiMethod`, because it is not
# associated with the package class.
- for cls in inspect.getmro(package_or_builder_self.__class__)[1:]:
+ for cls in package_or_builder_self.__class__.__mro__[1:]:
superself = cls.__dict__.get(self.__name__, None)
if isinstance(superself, SpecMultiMethod):
diff --git a/lib/spack/spack/package_base.py b/lib/spack/spack/package_base.py
index 40f71c4e9f..137c7f0645 100644
--- a/lib/spack/spack/package_base.py
+++ b/lib/spack/spack/package_base.py
@@ -878,7 +878,7 @@ class PackageBase(WindowsRPath, PackageViewMixin, RedistributionMixin, metaclass
def fullnames(cls):
"""Fullnames for this package and any packages from which it inherits."""
fullnames = []
- for cls in inspect.getmro(cls):
+ for cls in cls.__mro__:
namespace = getattr(cls, "namespace", None)
if namespace:
fullnames.append("%s.%s" % (namespace, cls.name))
diff --git a/lib/spack/spack/patch.py b/lib/spack/spack/patch.py
index 68f3f47bb2..6a57f49bb0 100644
--- a/lib/spack/spack/patch.py
+++ b/lib/spack/spack/patch.py
@@ -4,7 +4,6 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import hashlib
-import inspect
import os
import os.path
import pathlib
@@ -185,8 +184,8 @@ class FilePatch(Patch):
# search mro to look for the file
abs_path: Optional[str] = None
# At different times we call FilePatch on instances and classes
- pkg_cls = pkg if inspect.isclass(pkg) else pkg.__class__
- for cls in inspect.getmro(pkg_cls): # type: ignore
+ pkg_cls = pkg if isinstance(pkg, type) else pkg.__class__
+ for cls in pkg_cls.__mro__: # type: ignore
if not hasattr(cls, "module"):
# We've gone too far up the MRO
break
diff --git a/lib/spack/spack/repo.py b/lib/spack/spack/repo.py
index d565910289..1e95b4ec64 100644
--- a/lib/spack/spack/repo.py
+++ b/lib/spack/spack/repo.py
@@ -1281,7 +1281,7 @@ class Repo:
raise RepoError(msg) from e
cls = getattr(module, class_name)
- if not inspect.isclass(cls):
+ if not isinstance(cls, type):
tty.die(f"{pkg_name}.{class_name} is not a class")
# Clear any prior changes to class attributes in case the class was loaded from the
diff --git a/lib/spack/spack/test/build_environment.py b/lib/spack/spack/test/build_environment.py
index 3c381f368c..3d3bbf27cd 100644
--- a/lib/spack/spack/test/build_environment.py
+++ b/lib/spack/spack/test/build_environment.py
@@ -2,7 +2,6 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-import inspect
import os
import platform
import posixpath
@@ -593,7 +592,7 @@ class TestModuleMonkeyPatcher:
# We can also propagate the settings to classes in the MRO
module_wrapper.propagate_changes_to_mro()
- for cls in inspect.getmro(type(s.package)):
+ for cls in type(s.package).__mro__:
current_module = cls.module
if current_module == spack.package_base:
break
diff --git a/lib/spack/spack/test/spec_syntax.py b/lib/spack/spack/test/spec_syntax.py
index 3401575767..a4170715c1 100644
--- a/lib/spack/spack/test/spec_syntax.py
+++ b/lib/spack/spack/test/spec_syntax.py
@@ -2,7 +2,6 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-import inspect
import itertools
import os
import re
@@ -700,7 +699,7 @@ def test_parse_multiple_specs(text, tokens, expected_specs):
],
)
def test_cli_spec_roundtrip(args, expected):
- if inspect.isclass(expected) and issubclass(expected, BaseException):
+ if isinstance(expected, type) and issubclass(expected, BaseException):
with pytest.raises(expected):
spack.cmd.parse_specs(args)
return