summaryrefslogtreecommitdiff
path: root/lib/spack/llnl/util
diff options
context:
space:
mode:
authorAdam J. Stewart <ajstewart426@gmail.com>2023-07-05 07:37:44 -0500
committerGitHub <noreply@github.com>2023-07-05 14:37:44 +0200
commit95847a0b373d1fe55772ff39d58aa616bec88932 (patch)
tree742c3a2620c474d418c57ed14fd2e3207988d448 /lib/spack/llnl/util
parent8861fe029426649c15f273575e5d7e260c2febc6 (diff)
downloadspack-95847a0b373d1fe55772ff39d58aa616bec88932.tar.gz
spack-95847a0b373d1fe55772ff39d58aa616bec88932.tar.bz2
spack-95847a0b373d1fe55772ff39d58aa616bec88932.tar.xz
spack-95847a0b373d1fe55772ff39d58aa616bec88932.zip
Drop Python 2 object subclassing (#38720)
Diffstat (limited to 'lib/spack/llnl/util')
-rw-r--r--lib/spack/llnl/util/filesystem.py6
-rw-r--r--lib/spack/llnl/util/lang.py14
-rw-r--r--lib/spack/llnl/util/link_tree.py2
-rw-r--r--lib/spack/llnl/util/lock.py10
-rw-r--r--lib/spack/llnl/util/tty/color.py4
-rw-r--r--lib/spack/llnl/util/tty/log.py12
-rw-r--r--lib/spack/llnl/util/tty/pty.py4
7 files changed, 26 insertions, 26 deletions
diff --git a/lib/spack/llnl/util/filesystem.py b/lib/spack/llnl/util/filesystem.py
index 1a9f6835aa..fc681785ba 100644
--- a/lib/spack/llnl/util/filesystem.py
+++ b/lib/spack/llnl/util/filesystem.py
@@ -402,7 +402,7 @@ def filter_file(
os.remove(backup_filename)
-class FileFilter(object):
+class FileFilter:
"""Convenience class for calling ``filter_file`` a lot."""
def __init__(self, *filenames):
@@ -1338,7 +1338,7 @@ def lexists_islink_isdir(path):
return True, is_link, is_dir
-class BaseDirectoryVisitor(object):
+class BaseDirectoryVisitor:
"""Base class and interface for :py:func:`visit_directory_tree`."""
def visit_file(self, root, rel_path, depth):
@@ -2354,7 +2354,7 @@ def find_all_libraries(root, recursive=False):
)
-class WindowsSimulatedRPath(object):
+class WindowsSimulatedRPath:
"""Class representing Windows filesystem rpath analog
One instance of this class is associated with a package (only on Windows)
diff --git a/lib/spack/llnl/util/lang.py b/lib/spack/llnl/util/lang.py
index 98cb283ed4..c8ce562c07 100644
--- a/lib/spack/llnl/util/lang.py
+++ b/lib/spack/llnl/util/lang.py
@@ -769,7 +769,7 @@ class RequiredAttributeError(ValueError):
super(RequiredAttributeError, self).__init__(message)
-class ObjectWrapper(object):
+class ObjectWrapper:
"""Base class that wraps an object. Derived classes can add new behavior
while staying undercover.
@@ -796,7 +796,7 @@ class ObjectWrapper(object):
self.__dict__ = wrapped_object.__dict__
-class Singleton(object):
+class Singleton:
"""Simple wrapper for lazily initialized singleton objects."""
def __init__(self, factory):
@@ -843,7 +843,7 @@ class Singleton(object):
return repr(self.instance)
-class LazyReference(object):
+class LazyReference:
"""Lazily evaluated reference to part of a singleton."""
def __init__(self, ref_function):
@@ -941,7 +941,7 @@ def star(func):
return _wrapper
-class Devnull(object):
+class Devnull:
"""Null stream with less overhead than ``os.devnull``.
See https://stackoverflow.com/a/2929954.
@@ -1058,7 +1058,7 @@ class TypedMutableSequence(collections.abc.MutableSequence):
return str(self.data)
-class GroupedExceptionHandler(object):
+class GroupedExceptionHandler:
"""A generic mechanism to coalesce multiple exceptions and preserve tracebacks."""
def __init__(self):
@@ -1089,7 +1089,7 @@ class GroupedExceptionHandler(object):
return "due to the following failures:\n{0}".format("\n".join(each_exception_message))
-class GroupedExceptionForwarder(object):
+class GroupedExceptionForwarder:
"""A contextmanager to capture exceptions and forward them to a
GroupedExceptionHandler."""
@@ -1109,7 +1109,7 @@ class GroupedExceptionForwarder(object):
return True
-class classproperty(object):
+class classproperty:
"""Non-data descriptor to evaluate a class-level property. The function that performs
the evaluation is injected at creation time and take an instance (could be None) and
an owner (i.e. the class that originated the instance)
diff --git a/lib/spack/llnl/util/link_tree.py b/lib/spack/llnl/util/link_tree.py
index 88c8b7d1a4..64890252da 100644
--- a/lib/spack/llnl/util/link_tree.py
+++ b/lib/spack/llnl/util/link_tree.py
@@ -285,7 +285,7 @@ class DestinationMergeVisitor(BaseDirectoryVisitor):
self.visit_file(root, rel_path, depth)
-class LinkTree(object):
+class LinkTree:
"""Class to create trees of symbolic links from a source directory.
LinkTree objects are constructed with a source root. Their
diff --git a/lib/spack/llnl/util/lock.py b/lib/spack/llnl/util/lock.py
index 179ed50158..a60b49663e 100644
--- a/lib/spack/llnl/util/lock.py
+++ b/lib/spack/llnl/util/lock.py
@@ -39,7 +39,7 @@ __all__ = [
true_fn = lambda: True
-class OpenFile(object):
+class OpenFile:
"""Record for keeping track of open lockfiles (with reference counting).
There's really only one ``OpenFile`` per inode, per process, but we record the
@@ -53,7 +53,7 @@ class OpenFile(object):
self.refs = 0
-class OpenFileTracker(object):
+class OpenFileTracker:
"""Track open lockfiles, to minimize number of open file descriptors.
The ``fcntl`` locks that Spack uses are associated with an inode and a process.
@@ -169,7 +169,7 @@ def _attempts_str(wait_time, nattempts):
return " after {} and {}".format(pretty_seconds(wait_time), attempts)
-class LockType(object):
+class LockType:
READ = 0
WRITE = 1
@@ -192,7 +192,7 @@ class LockType(object):
return op == LockType.READ or op == LockType.WRITE
-class Lock(object):
+class Lock:
"""This is an implementation of a filesystem lock using Python's lockf.
In Python, ``lockf`` actually calls ``fcntl``, so this should work with
@@ -681,7 +681,7 @@ class Lock(object):
)
-class LockTransaction(object):
+class LockTransaction:
"""Simple nested transaction context manager that uses a file lock.
Arguments:
diff --git a/lib/spack/llnl/util/tty/color.py b/lib/spack/llnl/util/tty/color.py
index 0f508f0d06..84344a7ae7 100644
--- a/lib/spack/llnl/util/tty/color.py
+++ b/lib/spack/llnl/util/tty/color.py
@@ -203,7 +203,7 @@ def color_when(value):
set_color_when(old_value)
-class match_to_ansi(object):
+class match_to_ansi:
def __init__(self, color=True, enclose=False):
self.color = _color_when_value(color)
self.enclose = enclose
@@ -319,7 +319,7 @@ def cescape(string):
return string
-class ColorStream(object):
+class ColorStream:
def __init__(self, stream, color=None):
self._stream = stream
self._color = color
diff --git a/lib/spack/llnl/util/tty/log.py b/lib/spack/llnl/util/tty/log.py
index c325a8bf7d..f352d33ae5 100644
--- a/lib/spack/llnl/util/tty/log.py
+++ b/lib/spack/llnl/util/tty/log.py
@@ -65,7 +65,7 @@ def _strip(line):
return _escape.sub("", line)
-class keyboard_input(object):
+class keyboard_input:
"""Context manager to disable line editing and echoing.
Use this with ``sys.stdin`` for keyboard input, e.g.::
@@ -242,7 +242,7 @@ class keyboard_input(object):
signal.signal(signum, old_handler)
-class Unbuffered(object):
+class Unbuffered:
"""Wrapper for Python streams that forces them to be unbuffered.
This is implemented by forcing a flush after each write.
@@ -287,7 +287,7 @@ def _file_descriptors_work(*streams):
return False
-class FileWrapper(object):
+class FileWrapper:
"""Represents a file. Can be an open stream, a path to a file (not opened
yet), or neither. When unwrapped, it returns an open file (or file-like)
object.
@@ -329,7 +329,7 @@ class FileWrapper(object):
self.file.close()
-class MultiProcessFd(object):
+class MultiProcessFd:
"""Return an object which stores a file descriptor and can be passed as an
argument to a function run with ``multiprocessing.Process``, such that
the file descriptor is available in the subprocess."""
@@ -429,7 +429,7 @@ def log_output(*args, **kwargs):
return nixlog(*args, **kwargs)
-class nixlog(object):
+class nixlog:
"""
Under the hood, we spawn a daemon and set up a pipe between this
process and the daemon. The daemon writes our output to both the
@@ -750,7 +750,7 @@ class StreamWrapper:
os.close(self.saved_stream)
-class winlog(object):
+class winlog:
"""
Similar to nixlog, with underlying
functionality ported to support Windows.
diff --git a/lib/spack/llnl/util/tty/pty.py b/lib/spack/llnl/util/tty/pty.py
index 6f6433d390..60d5eee879 100644
--- a/lib/spack/llnl/util/tty/pty.py
+++ b/lib/spack/llnl/util/tty/pty.py
@@ -34,7 +34,7 @@ except ImportError:
pass
-class ProcessController(object):
+class ProcessController:
"""Wrapper around some fundamental process control operations.
This allows one process (the controller) to drive another (the
@@ -155,7 +155,7 @@ class ProcessController(object):
self.wait(lambda: "T" not in self.proc_status())
-class PseudoShell(object):
+class PseudoShell:
"""Sets up controller and minion processes with a PTY.
You can create a ``PseudoShell`` if you want to test how some