Drop Python 2 object subclassing (#38720)

This commit is contained in:
Adam J. Stewart
2023-07-05 07:37:44 -05:00
committed by GitHub
parent 8861fe0294
commit 95847a0b37
110 changed files with 233 additions and 233 deletions

View File

@@ -402,7 +402,7 @@ def groupid_to_group(x):
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)

View File

@@ -769,7 +769,7 @@ def __init__(self, message):
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 @@ def __init__(self, wrapped_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 @@ def __repr__(self):
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 _wrapper(args):
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 @@ def __str__(self):
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 @@ def grouped_message(self, with_tracebacks: bool = True) -> str:
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 @@ def __exit__(self, exc_type, exc_value, tb):
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)

View File

@@ -285,7 +285,7 @@ def visit_symlinked_file(self, root, rel_path, depth):
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

View File

@@ -39,7 +39,7 @@
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 @@ def __init__(self, fh):
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 @@ def is_valid(op):
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 @@ def _status_msg(self, locktype, status):
)
class LockTransaction(object):
class LockTransaction:
"""Simple nested transaction context manager that uses a file lock.
Arguments:

View File

@@ -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

View File

@@ -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 @@ def __exit__(self, exc_type, exception, traceback):
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 @@ def close(self):
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 @@ def close(self):
os.close(self.saved_stream)
class winlog(object):
class winlog:
"""
Similar to nixlog, with underlying
functionality ported to support Windows.

View File

@@ -34,7 +34,7 @@
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 @@ def wait_running(self):
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