diff options
author | Tim Harder <radhermit@gmail.com> | 2020-01-31 02:59:37 -0700 |
---|---|---|
committer | Tim Harder <radhermit@gmail.com> | 2020-01-31 02:59:37 -0700 |
commit | ac8820a69e8e6cd0062dd8596f2995815cf021dd (patch) | |
tree | cf4cfd6038b254374f0fc1b42465446a940ccd77 /src/snakeoil | |
parent | bump version and update news (diff) | |
download | snakeoil-ac8820a69e8e6cd0062dd8596f2995815cf021dd.tar.gz snakeoil-ac8820a69e8e6cd0062dd8596f2995815cf021dd.tar.bz2 snakeoil-ac8820a69e8e6cd0062dd8596f2995815cf021dd.zip |
drop unnecessary object class inheritance for py3
Diffstat (limited to 'src/snakeoil')
28 files changed, 59 insertions, 59 deletions
diff --git a/src/snakeoil/_fileutils.py b/src/snakeoil/_fileutils.py index 70cb7f0..51f82c7 100644 --- a/src/snakeoil/_fileutils.py +++ b/src/snakeoil/_fileutils.py @@ -29,7 +29,7 @@ def mmap_and_close(fd, *args, **kwargs): pass -class readlines_iter(object): +class readlines_iter: __slots__ = ("iterable", "mtime", "source") def __init__(self, iterable, mtime, close=True, source=None): if source is None: diff --git a/src/snakeoil/caching.py b/src/snakeoil/caching.py index 68e936f..3325872 100644 --- a/src/snakeoil/caching.py +++ b/src/snakeoil/caching.py @@ -25,7 +25,7 @@ There are some caveats to be aware of in using this metaclass: Simple usage example: >>> from snakeoil.caching import WeakInstMeta ->>> class myfoo(object, metaclass=WeakInstMeta): +>>> class myfoo(metaclass=WeakInstMeta): ... __inst_caching__ = True # safety measure turning caching on ... counter = 0 ... diff --git a/src/snakeoil/chksum/__init__.py b/src/snakeoil/chksum/__init__.py index dc75039..c4b770d 100644 --- a/src/snakeoil/chksum/__init__.py +++ b/src/snakeoil/chksum/__init__.py @@ -131,7 +131,7 @@ def get_chksums(location, *chksums, **kwds): parallelize=parallelize, can_mmap=can_mmap) -class LazilyHashedPath(object, metaclass=klass.immutable_instance): +class LazilyHashedPath(metaclass=klass.immutable_instance): """Given a pathway, compute chksums on demand via attribute access.""" def __init__(self, path, **initial_values): diff --git a/src/snakeoil/chksum/defaults.py b/src/snakeoil/chksum/defaults.py index 6b27650..16ae74f 100644 --- a/src/snakeoil/chksum/defaults.py +++ b/src/snakeoil/chksum/defaults.py @@ -113,7 +113,7 @@ def loop_over_file(handle, callbacks, parallelize=True, can_mmap=True): f.close() -class Chksummer(object): +class Chksummer: def __init__(self, chf_type, obj, str_size, can_mmap=True): self.obj = obj @@ -299,7 +299,7 @@ for k, v, str_size in ( del k, v -class SizeUpdater(object): +class SizeUpdater: def __init__(self): self.count = 0 diff --git a/src/snakeoil/cli/arghparse.py b/src/snakeoil/cli/arghparse.py index 7edf3f3..1507015 100644 --- a/src/snakeoil/cli/arghparse.py +++ b/src/snakeoil/cli/arghparse.py @@ -308,7 +308,7 @@ class Verbosity(argparse.Action): setattr(namespace, self.dest, new) -class DelayedValue(object): +class DelayedValue: def __init__(self, invokable, priority=0): self.priority = priority @@ -1232,7 +1232,7 @@ class ArgumentParser(OptionalsParser, CsvActionsParser): return functor -class ArgparseCommand(object): +class ArgparseCommand: def bind_to_parser(self, parser): parser.bind_main_func(self) diff --git a/src/snakeoil/cli/tool.py b/src/snakeoil/cli/tool.py index c16695c..f966be1 100644 --- a/src/snakeoil/cli/tool.py +++ b/src/snakeoil/cli/tool.py @@ -14,7 +14,7 @@ from ..contexts import nullcontext from ..log import suppress_logging -class Tool(object): +class Tool: """Abstraction for commandline tools.""" def __init__(self, parser, outfile=None, errfile=None): diff --git a/src/snakeoil/compatibility.py b/src/snakeoil/compatibility.py index 66df84f..29fa1c8 100644 --- a/src/snakeoil/compatibility.py +++ b/src/snakeoil/compatibility.py @@ -15,7 +15,7 @@ if hasattr(sys, 'getPlatform'): def sorted_key_from_cmp(cmp_func, key_func=None): - class _key_proxy(object): + class _key_proxy: __slots__ = ('_obj',) diff --git a/src/snakeoil/compression/__init__.py b/src/snakeoil/compression/__init__.py index 6addd22..1b62f46 100644 --- a/src/snakeoil/compression/__init__.py +++ b/src/snakeoil/compression/__init__.py @@ -7,7 +7,7 @@ from ..process import find_binary, CommandNotFound from ..process.spawn import spawn_get_output -class _transform_source(object): +class _transform_source: def __init__(self, name): self.name = name @@ -73,7 +73,7 @@ class _RegisterCompressionFormat(type): return new_cls -class ArComp(object): +class ArComp: """Generic archive and compressed file format support.""" binary = None diff --git a/src/snakeoil/containers.py b/src/snakeoil/containers.py index c9c3eae..11a224e 100644 --- a/src/snakeoil/containers.py +++ b/src/snakeoil/containers.py @@ -38,7 +38,7 @@ class InvertedContains(set): raise TypeError("InvertedContains cannot be iterated over") -class SetMixin(object): +class SetMixin: """ Base class for implementing set classes diff --git a/src/snakeoil/contexts.py b/src/snakeoil/contexts.py index 0e9ddaf..4b54fba 100644 --- a/src/snakeoil/contexts.py +++ b/src/snakeoil/contexts.py @@ -40,7 +40,7 @@ from .process import namespaces # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -class SplitExec(object): +class SplitExec: """Context manager separating code execution across parent/child processes. This is done by forking and doing some magic on the stack so the contents diff --git a/src/snakeoil/currying.py b/src/snakeoil/currying.py index 8f42dfe..72a0318 100644 --- a/src/snakeoil/currying.py +++ b/src/snakeoil/currying.py @@ -11,7 +11,7 @@ is this ... return arg, self >>> curry = pre_curry(func, True) >>> part = partial(func, True) ->>> class Test(object): +>>> class Test: ... curry = pre_curry(func, True) ... part = partial(func, True) ... def __repr__(self): diff --git a/src/snakeoil/data_source.py b/src/snakeoil/data_source.py index ec67ab0..3e45960 100644 --- a/src/snakeoil/data_source.py +++ b/src/snakeoil/data_source.py @@ -122,7 +122,7 @@ def open_file(*args, **kwds): return handle -class base(object): +class base: """ base data_source class; implementations of the protocol are advised to derive from this. diff --git a/src/snakeoil/demandload.py b/src/snakeoil/demandload.py index ac9374d..00b83a3 100644 --- a/src/snakeoil/demandload.py +++ b/src/snakeoil/demandload.py @@ -123,7 +123,7 @@ else: _noisy_protection = _noisy_protection_enabled -class Placeholder(object): +class Placeholder: """Object that knows how to replace itself when first accessed. diff --git a/src/snakeoil/dependant_methods.py b/src/snakeoil/dependant_methods.py index 62c25f1..551af1e 100644 --- a/src/snakeoil/dependant_methods.py +++ b/src/snakeoil/dependant_methods.py @@ -17,7 +17,7 @@ all necessary steps will be ran in the correct order. Example usage: >>> from snakeoil.dependant_methods import ForcedDepends ->>> class foo(object, metaclass=ForcedDepends): +>>> class foo(metaclass=ForcedDepends): ... stage_depends = {"finish": ("do_step1", "do_step2"), ... "do_step1":"start", "do_step2": "start"} ... diff --git a/src/snakeoil/descriptors.py b/src/snakeoil/descriptors.py index b328901..12f51cb 100644 --- a/src/snakeoil/descriptors.py +++ b/src/snakeoil/descriptors.py @@ -3,7 +3,7 @@ __all__ = ("classproperty",) -class classproperty(object): +class classproperty: """Like the builtin :py:func:`property` but takes a single classmethod. @@ -13,7 +13,7 @@ class classproperty(object): Used like this: >>> from snakeoil.descriptors import classproperty - >>> class foo(object): + >>> class foo: ... ... @classproperty ... def test(cls): diff --git a/src/snakeoil/dist/generate_man_rsts.py b/src/snakeoil/dist/generate_man_rsts.py index d2ecc92..7309a1f 100644 --- a/src/snakeoil/dist/generate_man_rsts.py +++ b/src/snakeoil/dist/generate_man_rsts.py @@ -41,7 +41,7 @@ class RawTextFormatter(argparse.RawTextHelpFormatter): return super()._format_action(action) -class ManConverter(object): +class ManConverter: """Convert argparse help docs into rST man pages.""" positional_re = re.compile("^([^: \t]+)") diff --git a/src/snakeoil/fileutils.py b/src/snakeoil/fileutils.py index 33510a9..ff4bcba 100644 --- a/src/snakeoil/fileutils.py +++ b/src/snakeoil/fileutils.py @@ -68,7 +68,7 @@ def mmap_or_open_for_read(path): raise -class UnbufferedWriteHandle(object): +class UnbufferedWriteHandle: """Class designed to work around py3k buffering issues see http://stackoverflow.com/questions/107705/python-output-buffering @@ -84,7 +84,7 @@ class UnbufferedWriteHandle(object): __getattr__ = GetAttrProxy("stream") -class AtomicWriteFile_mixin(object): +class AtomicWriteFile_mixin: """File class that stores the changes in a tempfile. diff --git a/src/snakeoil/formatters.py b/src/snakeoil/formatters.py index 74c13fc..3021911 100644 --- a/src/snakeoil/formatters.py +++ b/src/snakeoil/formatters.py @@ -30,7 +30,7 @@ class native_StreamClosed(KeyboardInterrupt): # pylint: disable=C0103 -class Formatter(object): +class Formatter: """ Abstract formatter base class. @@ -363,7 +363,7 @@ try: except ImportError: TerminfoColor = None else: - class TerminfoColor(object): + class TerminfoColor: """ class encapsulating a specific terminfo entry for a color @@ -405,7 +405,7 @@ else: raise AttributeError("%s instances are immutable" % (self.__class__.__name__,)) - class TerminfoCode(object): + class TerminfoCode: """ Encapsulates specific terminfo entry commands, reset for example. @@ -568,7 +568,7 @@ else: self.stream.flush() -class ObserverFormatter(object): +class ObserverFormatter: def __init__(self, real_formatter): self._formatter = real_formatter diff --git a/src/snakeoil/iterables.py b/src/snakeoil/iterables.py index 12f0aed..9b5bb26 100644 --- a/src/snakeoil/iterables.py +++ b/src/snakeoil/iterables.py @@ -25,7 +25,7 @@ def partition(iterable, predicate=bool): (x for pred, x in b if pred)) -class expandable_chain(object): +class expandable_chain: """ chained iterables, with the ability to add new iterables to the chain as long as the instance hasn't raised StopIteration already. This is @@ -94,7 +94,7 @@ class expandable_chain(object): self.iterables.extendleft(iter(x) for x in iterables) -class caching_iter(object): +class caching_iter: """ On demand consumes from an iterable so as to appear like a tuple diff --git a/src/snakeoil/klass.py b/src/snakeoil/klass.py index e794a9c..c59c835 100644 --- a/src/snakeoil/klass.py +++ b/src/snakeoil/klass.py @@ -127,7 +127,7 @@ def _native_internal_jit_attr( use_singleton=use_singleton) -class _raw_native_internal_jit_attr(object): +class _raw_native_internal_jit_attr: """See _native_internal_jit_attr; this is an implementation detail of that""" __slots__ = ("storage_attr", "function", "_setter", "singleton", "use_singleton") @@ -205,7 +205,7 @@ def generic_equality(name, bases, scope, real_type=type, :raise: TypeError if __attr_comparison__ is incorrectly defined >>> from snakeoil.klass import generic_equality - >>> class foo(object, metaclass=generic_equality): + >>> class foo(metaclass=generic_equality): ... __attr_comparison__ = ("a", "b", "c") ... def __init__(self, a=1, b=2, c=3): ... self.a, self.b, self.c = a, b, c @@ -276,7 +276,7 @@ def inject_richcmp_methods_from_cmp(scope, inject_always=False): >>> from snakeoil.klass import inject_richcmp_methods_from_cmp >>> from snakeoil.compatibility import cmp - >>> class foo(object): + >>> class foo: ... ... # note that for this example, we inject always since we're ... # explicitly accessing __ge__ methods- under py2k, they wouldn't @@ -310,7 +310,7 @@ def inject_richcmp_methods_from_cmp(scope, inject_always=False): scope.setdefault(key, func) -class chained_getter(object, metaclass=partial(generic_equality, real_type=caching.WeakInstMeta)): +class chained_getter(metaclass=partial(generic_equality, real_type=caching.WeakInstMeta)): """ object that will do multi part lookup, regardless of if it's in the context @@ -329,7 +329,7 @@ class chained_getter(object, metaclass=partial(generic_equality, real_type=cachi >>> print(chained_getter("extend")(list).__name__) extend >>> - >>> class foo(object): + >>> class foo: ... ... seq = (1,2,3) ... @@ -379,7 +379,7 @@ instance_attrgetter = chained_getter # we suppress the repr since if it's unmodified, it'll expose the id; # this annoyingly means our docs have to be recommited every change, # even if no real code changed (since the id() continually moves)... -class _singleton_kls(object): +class _singleton_kls: def __str__(self): return "uncached singleton instance" @@ -454,7 +454,7 @@ def cached_property(func, kls=_internal_jit_attr, use_cls_setattr=False): Example Usage: >>> from snakeoil.klass import cached_property - >>> class foo(object): + >>> class foo: ... ... @cached_property ... def attr(self): @@ -480,7 +480,7 @@ def cached_property_named(name, kls=_internal_jit_attr, use_cls_setattr=False): Example Usage: >>> from snakeoil.klass import cached_property_named - >>> class foo(object): + >>> class foo: ... ... @cached_property_named("attr") ... def attr(self): @@ -505,7 +505,7 @@ def alias_attr(target_attr): Example Usage: >>> from snakeoil.klass import alias_attr - >>> class foo(object): + >>> class foo: ... ... seq = (1,2,3) ... @@ -535,7 +535,7 @@ def cached_hash(func): if you know it cannot change. >>> from snakeoil.klass import cached_hash - >>> class foo(object): + >>> class foo: ... def __init__(self): ... self.hash_invocations = 0 ... @@ -694,7 +694,7 @@ def inject_immutable_instance(scope): scope.setdefault("__delattr__", _immutable_delattr) -class ImmutableInstance(object): +class ImmutableInstance: """Class that disables surface-level attribute modifications.""" __setattr__ = _immutable_setattr @@ -720,7 +720,7 @@ def alias_method(attr, name=None, doc=None): :param doc: ``__doc__`` to force for the new method if desired >>> from snakeoil.klass import alias_method - >>> class foon(object): + >>> class foon: ... def orig(self): ... return 1 ... alias = alias_method("orig") @@ -742,7 +742,7 @@ def alias_method(attr, name=None, doc=None): return _asecond_level_call -class alias(object): +class alias: """Decorator for making methods callable through aliases. This decorator must be used inside a class decorated with @aliased. @@ -751,7 +751,7 @@ class alias(object): >>> from snakeoil.klass import aliased, alias >>> @aliased - >>> class Speak(object): + >>> class Speak: ... @alias('yell', 'scream') ... def shout(message): ... return message.upper() @@ -784,7 +784,7 @@ def aliased(cls): return cls -class SlotsPicklingMixin(object): +class SlotsPicklingMixin: """Default pickling support for classes that use __slots__.""" __slots__ = () diff --git a/src/snakeoil/mappings.py b/src/snakeoil/mappings.py index e044ea1..7c3d526 100644 --- a/src/snakeoil/mappings.py +++ b/src/snakeoil/mappings.py @@ -18,7 +18,7 @@ import operator from .klass import get, contains, steal_docs, _sentinel -class DictMixin(object): +class DictMixin: """ new style class replacement for :py:func:`UserDict.DictMixin` designed around iter* methods rather then forcing lists as DictMixin does @@ -346,7 +346,7 @@ class ImmutableDict(Mapping): return hash(tuple(sorted(self._dict.items(), key=operator.itemgetter(0)))) -class IndeterminantDict(object): +class IndeterminantDict: """A wrapped dict with constant defaults, and a function for other keys. The primary use for this class is to make a JIT loaded mapping- for instance, a @@ -605,7 +605,7 @@ class ProxiedAttrs(DictMixin): Example usage: - >>> class foo(object): + >>> class foo: ... pass >>> obj = foo() >>> obj.x, obj.y = 1, 2 @@ -665,7 +665,7 @@ def native_attr_contains(self, key): # python issue 7604; depending on the python version, delattr'ing an empty slot # doesn't throw AttributeError; we vary our implementation for efficiency # dependent on a onetime runtime test of that. -class foo(object): +class foo: __slots__ = ("slot",) # track which is required since if we can use extensions, we'll have diff --git a/src/snakeoil/obj.py b/src/snakeoil/obj.py index 35118b9..a5d67db 100644 --- a/src/snakeoil/obj.py +++ b/src/snakeoil/obj.py @@ -26,7 +26,7 @@ By and large, this proxying is transparent if dealing in python objects (newstyl for example, >>> from snakeoil.obj import DelayedInstantiation_kls ->>> class foo(object): +>>> class foo: ... def __init__(self, value): ... print("instance was created") ... self.attribute = value @@ -108,7 +108,7 @@ def popattr(obj, name, default=klass._sentinel): getattr(obj, name) -class BaseDelayedObject(object): +class BaseDelayedObject: """ Base proxying object diff --git a/src/snakeoil/osutils/__init__.py b/src/snakeoil/osutils/__init__.py index 0e29a4e..4a4544f 100644 --- a/src/snakeoil/osutils/__init__.py +++ b/src/snakeoil/osutils/__init__.py @@ -314,7 +314,7 @@ class GenericFailed(LockException): # IMO, it shouldn't, but opening/closing everytime around is expensive -class FsLock(object): +class FsLock: """fnctl based filesystem lock""" __slots__ = ("path", "fd", "create") diff --git a/src/snakeoil/sequences.py b/src/snakeoil/sequences.py index 6ee263c..5239d0a 100644 --- a/src/snakeoil/sequences.py +++ b/src/snakeoil/sequences.py @@ -148,7 +148,7 @@ except ImportError: iflatten_func = native_iflatten_func -class ChainedLists(object): +class ChainedLists: """Given a set of sequences, this will act as a proxy to them without collapsing them into a single list. This is primarily useful when you're dealing in large sets (or custom diff --git a/src/snakeoil/test/__init__.py b/src/snakeoil/test/__init__.py index a69ec26..51d64b4 100644 --- a/src/snakeoil/test/__init__.py +++ b/src/snakeoil/test/__init__.py @@ -79,7 +79,7 @@ def not_a_test(obj): not_a_test = not_a_test(not_a_test) -class Todo(object): +class Todo: def __init__(self, reason, errors=None): self.reason = reason @@ -106,7 +106,7 @@ class Todo(object): return False -class TestCase(unittest.TestCase, object): +class TestCase(unittest.TestCase): """Our additions to the standard TestCase. diff --git a/src/snakeoil/test/argparse_helpers.py b/src/snakeoil/test/argparse_helpers.py index 34326cf..bcb0679 100644 --- a/src/snakeoil/test/argparse_helpers.py +++ b/src/snakeoil/test/argparse_helpers.py @@ -41,7 +41,7 @@ def mangle_parser(parser): return parser -class FormatterObject(object, metaclass=WeakInstMeta): +class FormatterObject(metaclass=WeakInstMeta): __inst_caching__ = True def __call__(self, formatter): @@ -116,7 +116,7 @@ class FakeStreamFormatter(PlainTextFormatter): if not isinstance(x, FormatterObject)]).decode('ascii') -class ArgParseMixin(object): +class ArgParseMixin: """Provide some utility methods for testing the parser and main. :cvar parser: ArgumentParser subclass to test. diff --git a/src/snakeoil/test/fixtures.py b/src/snakeoil/test/fixtures.py index 3262e0a..2526b14 100644 --- a/src/snakeoil/test/fixtures.py +++ b/src/snakeoil/test/fixtures.py @@ -5,7 +5,7 @@ import pytest from . import random_str -class TempDir(object): +class TempDir: """Provide temporary directory to every test method.""" @pytest.fixture(autouse=True) @@ -13,7 +13,7 @@ class TempDir(object): self.dir = str(tmpdir) -class RandomPath(object): +class RandomPath: """Provide random path in a temporary directory to every test method.""" @pytest.fixture(autouse=True) diff --git a/src/snakeoil/test/mixins.py b/src/snakeoil/test/mixins.py index 45bba41..270a71d 100644 --- a/src/snakeoil/test/mixins.py +++ b/src/snakeoil/test/mixins.py @@ -48,7 +48,7 @@ def mk_named_tempfile(*args, **kwds): return io.TextIOWrapper(tmp_f) -class PythonNamespaceWalker(object): +class PythonNamespaceWalker: ignore_all_import_failures = False @@ -178,7 +178,7 @@ class TargetedNamespaceWalker(PythonNamespaceWalker): for _mod in self.walk_namespace(namespace): pass -class _classWalker(object): +class _classWalker: cls_blacklist = frozenset() |