diff options
author | Jon Dufresne <jon.dufresne@gmail.com> | 2018-09-11 16:48:35 +0300 |
---|---|---|
committer | Jon Dufresne <jon.dufresne@gmail.com> | 2018-09-11 17:07:01 +0300 |
commit | 490e4aed4145659dab000e86269bd7a3dc686318 (patch) | |
tree | 87b32f22ae1ff41b03877a68bbb8ab4f1c2c9ab7 | |
parent | 844a3a5c226ff8891a1ce139f10ac92157c75da5 (diff) |
Remove unnecessary object from class definitions
In Python 3, all classes are new-style classes. The object in the
definition is redundant and unnecessary.
70 files changed, 115 insertions, 116 deletions
diff --git a/doc/usage/extensions/example_google.py b/doc/usage/extensions/example_google.py index 4f6abacdf..07870297e 100644 --- a/doc/usage/extensions/example_google.py +++ b/doc/usage/extensions/example_google.py @@ -178,7 +178,7 @@ class ExampleError(Exception): self.code = code -class ExampleClass(object): +class ExampleClass: """The summary line for a class docstring should fit on one line. If the class has public attributes, they may be documented here diff --git a/doc/usage/extensions/example_numpy.py b/doc/usage/extensions/example_numpy.py index dbee080c3..479aea489 100644 --- a/doc/usage/extensions/example_numpy.py +++ b/doc/usage/extensions/example_numpy.py @@ -223,7 +223,7 @@ class ExampleError(Exception): self.code = code -class ExampleClass(object): +class ExampleClass: """The summary line for a class docstring should fit on one line. If the class has public attributes, they may be documented here diff --git a/doc/usage/extensions/inheritance.rst b/doc/usage/extensions/inheritance.rst index ef78d04fe..c66f4130f 100644 --- a/doc/usage/extensions/inheritance.rst +++ b/doc/usage/extensions/inheritance.rst @@ -54,7 +54,7 @@ It adds this directive: E D F """ - class A(object): + class A: pass class B(A): @@ -56,7 +56,7 @@ extras_require = { cmdclass = {} -class Tee(object): +class Tee: def __init__(self, stream): self.stream = stream self.buffer = StringIO() diff --git a/sphinx/addnodes.py b/sphinx/addnodes.py index 331fe5225..b69533751 100644 --- a/sphinx/addnodes.py +++ b/sphinx/addnodes.py @@ -20,7 +20,7 @@ if False: from typing import List, Sequence # NOQA -class translatable(object): +class translatable: """Node which supports translation. The translation goes forward with following steps: @@ -53,7 +53,7 @@ class translatable(object): raise NotImplementedError -class not_smartquotable(object): +class not_smartquotable: """A node which does not support smart-quotes.""" support_smartquotes = False diff --git a/sphinx/application.py b/sphinx/application.py index e240ec869..cbf8540b0 100644 --- a/sphinx/application.py +++ b/sphinx/application.py @@ -118,7 +118,7 @@ ENV_PICKLE_FILENAME = 'environment.pickle' logger = logging.getLogger(__name__) -class Sphinx(object): +class Sphinx: """The main application class and extensibility interface. :ivar srcdir: Directory containing source. @@ -1208,7 +1208,7 @@ class Sphinx(object): return True -class TemplateBridge(object): +class TemplateBridge: """ This class defines the interface for a "template bridge", that is, a class that renders templates given a template name and a context. diff --git a/sphinx/builders/__init__.py b/sphinx/builders/__init__.py index 6fc7c7152..517f435d4 100644 --- a/sphinx/builders/__init__.py +++ b/sphinx/builders/__init__.py @@ -52,7 +52,7 @@ if False: logger = logging.getLogger(__name__) -class Builder(object): +class Builder: """ Builds target formats from the reST sources. """ diff --git a/sphinx/builders/gettext.py b/sphinx/builders/gettext.py index b43dcfb3b..508301f79 100644 --- a/sphinx/builders/gettext.py +++ b/sphinx/builders/gettext.py @@ -62,7 +62,7 @@ msgstr "" """[1:] -class Catalog(object): +class Catalog: """Catalog of translatable messages.""" def __init__(self): @@ -84,7 +84,7 @@ class Catalog(object): self.metadata[msg].append((origin.source, origin.line, origin.uid)) -class MsgOrigin(object): +class MsgOrigin: """ Origin holder for Catalog message origin. """ diff --git a/sphinx/builders/html.py b/sphinx/builders/html.py index 3c08cc818..830c2cce3 100644 --- a/sphinx/builders/html.py +++ b/sphinx/builders/html.py @@ -169,7 +169,7 @@ class JavaScript(text_type): return self -class BuildInfo(object): +class BuildInfo: """buildinfo file manipulator. HTMLBuilder and its family are storing their own envdata to ``.buildinfo``. diff --git a/sphinx/cmd/make_mode.py b/sphinx/cmd/make_mode.py index cf8673623..447b2ed01 100644 --- a/sphinx/cmd/make_mode.py +++ b/sphinx/cmd/make_mode.py @@ -59,7 +59,7 @@ BUILDERS = [ ] -class Make(object): +class Make: def __init__(self, srcdir, builddir, opts): # type: (unicode, unicode, List[unicode]) -> None diff --git a/sphinx/config.py b/sphinx/config.py index 039bf7b6a..d90569e42 100644 --- a/sphinx/config.py +++ b/sphinx/config.py @@ -49,7 +49,7 @@ ConfigValue = NamedTuple('ConfigValue', [('name', str), ('rebuild', Union[bool, unicode])]) -class ENUM(object): +class ENUM: """represents the config value should be a one of candidates. Example: @@ -72,7 +72,7 @@ if PY2: string_classes.append(binary_type) # => [str, unicode] -class Config(object): +class Config: """Configuration file abstraction. The config object makes the values of all config values available as diff --git a/sphinx/directives/code.py b/sphinx/directives/code.py index a98ab5883..868787a14 100644 --- a/sphinx/directives/code.py +++ b/sphinx/directives/code.py @@ -177,7 +177,7 @@ class CodeBlock(SphinxDirective): return [literal] -class LiteralIncludeReader(object): +class LiteralIncludeReader: INVALID_OPTIONS_PAIR = [ ('lineno-match', 'lineno-start'), ('lineno-match', 'append'), diff --git a/sphinx/domains/__init__.py b/sphinx/domains/__init__.py index 41db13cb6..e8c3a59dd 100644 --- a/sphinx/domains/__init__.py +++ b/sphinx/domains/__init__.py @@ -28,7 +28,7 @@ if False: from sphinx.util.typing import RoleFunction # NOQA -class ObjType(object): +class ObjType: """ An ObjType is the description for a type of object that a domain can document. In the object_types attribute of Domain subclasses, object type @@ -55,7 +55,7 @@ class ObjType(object): self.attrs.update(attrs) -class Index(object): +class Index: """ An Index is the description for a domain-specific index. To add an index to a domain, subclass Index, overriding the three name attributes: @@ -113,7 +113,7 @@ class Index(object): raise NotImplementedError -class Domain(object): +class Domain: """ A Domain is meant to be a group of "object" description directives for objects of a similar nature, and corresponding roles to create references to diff --git a/sphinx/domains/cpp.py b/sphinx/domains/cpp.py index 5d556e777..9c797cd36 100644 --- a/sphinx/domains/cpp.py +++ b/sphinx/domains/cpp.py @@ -3592,7 +3592,7 @@ class ASTNamespace(ASTBase): self.templatePrefix = templatePrefix -class SymbolLookupResult(object): +class SymbolLookupResult: def __init__(self, symbols, parentSymbol, identOrOp, templateParams, templateArgs): # type: (Iterator[Symbol], Symbol, Union[ASTIdentifier, ASTOperator], Any, ASTTemplateArgs) -> None # NOQA self.symbols = symbols @@ -3602,7 +3602,7 @@ class SymbolLookupResult(object): self.templateArgs = templateArgs -class Symbol(object): +class Symbol: debug_lookup = False def _assert_invariants(self): @@ -4293,7 +4293,7 @@ class Symbol(object): return ''.join(res) -class DefinitionParser(object): +class DefinitionParser: # those without signedness and size modifiers # see http://en.cppreference.com/w/cpp/language/types _simple_fundemental_types = ( @@ -6585,7 +6585,7 @@ class CPPXRefRole(XRefRole): return title, target -class CPPExprRole(object): +class CPPExprRole: def __init__(self, asCode): if asCode: # render the expression as inline code @@ -6597,7 +6597,7 @@ class CPPExprRole(object): self.node_type = nodes.inline def __call__(self, typ, rawtext, text, lineno, inliner, options={}, content=[]): - class Warner(object): + class Warner: def warn(self, msg): inliner.reporter.warning(msg, line=lineno) text = utils.unescape(text).replace('\n', ' ') @@ -6716,7 +6716,7 @@ class CPPDomain(Domain): target, node, contnode, emitWarnings=True): # type: (BuildEnvironment, unicode, Builder, unicode, unicode, nodes.Node, nodes.Node, bool) -> nodes.Node # NOQA - class Warner(object): + class Warner: def warn(self, msg): if emitWarnings: logger.warning(msg, location=node) diff --git a/sphinx/domains/python.py b/sphinx/domains/python.py index fe9bb9090..5f822aeca 100644 --- a/sphinx/domains/python.py +++ b/sphinx/domains/python.py @@ -114,7 +114,7 @@ def _pseudo_parse_arglist(signode, arglist): # This override allows our inline type specifiers to behave like :class: link # when it comes to handling "." and "~" prefixes. -class PyXrefMixin(object): +class PyXrefMixin: def make_xref(self, rolename, # type: unicode domain, # type: unicode @@ -536,7 +536,7 @@ class PyClassmember(PyObject): return '' -class PyDecoratorMixin(object): +class PyDecoratorMixin: """ Mixin for decorator directives. """ diff --git a/sphinx/environment/__init__.py b/sphinx/environment/__init__.py index 4f91e2f8e..ce050d906 100644 --- a/sphinx/environment/__init__.py +++ b/sphinx/environment/__init__.py @@ -91,7 +91,7 @@ class NoUri(Exception): pass -class BuildEnvironment(object): +class BuildEnvironment: """ The environment in which the ReST files are translated. Stores an inventory of cross-file targets and provides doctree diff --git a/sphinx/environment/adapters/asset.py b/sphinx/environment/adapters/asset.py index 91f2cf8eb..fa1141f65 100644 --- a/sphinx/environment/adapters/asset.py +++ b/sphinx/environment/adapters/asset.py @@ -14,7 +14,7 @@ if False: from sphinx.environment import BuildEnvironment # NOQA -class ImageAdapter(object): +class ImageAdapter: def __init__(self, env): # type: (BuildEnvironment) -> None self.env = env diff --git a/sphinx/environment/adapters/indexentries.py b/sphinx/environment/adapters/indexentries.py index 7c31fc3d5..5f5da0b1e 100644 --- a/sphinx/environment/adapters/indexentries.py +++ b/sphinx/environment/adapters/indexentries.py @@ -27,7 +27,7 @@ if False: logger = logging.getLogger(__name__) -class IndexEntries(object): +class IndexEntries: def __init__(self, env): # type: (BuildEnvironment) -> None self.env = env diff --git a/sphinx/environment/adapters/toctree.py b/sphinx/environment/adapters/toctree.py index 565396ec4..387e04886 100644 --- a/sphinx/environment/adapters/toctree.py +++ b/sphinx/environment/adapters/toctree.py @@ -27,7 +27,7 @@ if False: logger = logging.getLogger(__name__) -class TocTree(object): +class TocTree: def __init__(self, env): # type: (BuildEnvironment) -> None self.env = env diff --git a/sphinx/environment/collectors/__init__.py b/sphinx/environment/collectors/__init__.py index 9d9f5347c..9427d3731 100644 --- a/sphinx/environment/collectors/__init__.py +++ b/sphinx/environment/collectors/__init__.py @@ -19,7 +19,7 @@ if False: from sphinx.environment import BuildEnvironment # NOQA -class EnvironmentCollector(object): +class EnvironmentCollector: """An EnvironmentCollector is a specific data collector from each document. It gathers data and stores :py:class:`BuildEnvironment diff --git a/sphinx/events.py b/sphinx/events.py index fb62d1776..7ec805738 100644 --- a/sphinx/events.py +++ b/sphinx/events.py @@ -45,7 +45,7 @@ core_events = { } # type: Dict[unicode, unicode] -class EventManager(object): +class EventManager: def __init__(self): # type: () -> None self.events = core_events.copy() diff --git a/sphinx/ext/autodoc/__init__.py b/sphinx/ext/autodoc/__init__.py index 4129e17c6..ac7080593 100644 --- a/sphinx/ext/autodoc/__init__.py +++ b/sphinx/ext/autodoc/__init__.py @@ -199,7 +199,7 @@ class Options(dict): return None -class Documenter(object): +class Documenter: """ A Documenter knows how to autodocument a single object type. When registered with the AutoDirective, it will be used to document objects @@ -916,7 +916,7 @@ class ClassLevelDocumenter(Documenter): return modname, parents + [base] -class DocstringSignatureMixin(object): +class DocstringSignatureMixin: """ Mixin for FunctionDocumenter and MethodDocumenter to provide the feature of reading the signature from the docstring. diff --git a/sphinx/ext/autodoc/directive.py b/sphinx/ext/autodoc/directive.py index 3a3434fc8..e831cab64 100644 --- a/sphinx/ext/autodoc/directive.py +++ b/sphinx/ext/autodoc/directive.py @@ -34,7 +34,7 @@ AUTODOC_DEFAULT_OPTIONS = ['members', 'undoc-members', 'inherited-members', 'ignore-module-all', 'exclude-members'] -class DummyOptionSpec(object): +class DummyOptionSpec: """An option_spec allows any options.""" def __getitem__(self, key): @@ -42,7 +42,7 @@ class DummyOptionSpec(object): return lambda x: x -class DocumenterBridge(object): +class DocumenterBridge: """A parameters container for Documenters.""" def __init__(self, env, reporter, options, lineno): diff --git a/sphinx/ext/autodoc/importer.py b/sphinx/ext/autodoc/importer.py index 041589b58..eba3412d5 100644 --- a/sphinx/ext/autodoc/importer.py +++ b/sphinx/ext/autodoc/importer.py @@ -28,7 +28,7 @@ if False: logger = logging.getLogger(__name__) -class _MockObject(object): +class _MockObject: """Used by autodoc_mock_imports.""" def __new__(cls, *args, **kwargs): @@ -93,7 +93,7 @@ class _MockModule(ModuleType): return o -class _MockImporter(object): +class _MockImporter: def __init__(self, names): # type: (List[str]) -> None self.names = names diff --git a/sphinx/ext/autosummary/generate.py b/sphinx/ext/autosummary/generate.py index dbadfe8d5..14f533f0c 100644 --- a/sphinx/ext/autosummary/generate.py +++ b/sphinx/ext/autosummary/generate.py @@ -51,7 +51,7 @@ if False: from sphinx.ext.autodoc import Documenter # NOQA -class DummyApplication(object): +class DummyApplication: """Dummy Application class for sphinx-autogen command.""" def __init__(self): diff --git a/sphinx/ext/doctest.py b/sphinx/ext/doctest.py index fa6cbed6d..e69346462 100644 --- a/sphinx/ext/doctest.py +++ b/sphinx/ext/doctest.py @@ -203,7 +203,7 @@ parser = doctest.DocTestParser() # helper classes -class TestGroup(object): +class TestGroup: def __init__(self, name): # type: (unicode) -> None self.name = name @@ -236,7 +236,7 @@ class TestGroup(object): self.name, self.setup, self.cleanup, self.tests) -class TestCode(object): +class TestCode: def __init__(self, code, type, filename, lineno, options=None): # type: (unicode, unicode, Optional[str], int, Optional[Dict]) -> None self.code = code diff --git a/sphinx/ext/graphviz.py b/sphinx/ext/graphviz.py index cf606f3b7..1a56536de 100644 --- a/sphinx/ext/graphviz.py +++ b/sphinx/ext/graphviz.py @@ -44,7 +44,7 @@ class GraphvizError(SphinxError): category = 'Graphviz error' -class ClickableMapDefinition(object): +class ClickableMapDefinition: """A manipulator for clickable map file of graphviz.""" maptag_re = re.compile('<map id="(.*?)"') href_re = re.compile('href=".*?"') diff --git a/sphinx/ext/inheritance_diagram.py b/sphinx/ext/inheritance_diagram.py index d91848aa1..0046026df 100644 --- a/sphinx/ext/inheritance_diagram.py +++ b/sphinx/ext/inheritance_diagram.py @@ -129,7 +129,7 @@ class InheritanceException(Exception): pass -class InheritanceGraph(object): +class InheritanceGraph: """ Given a list of classes, determines the set of classes that they inherit from all the way to the root "object", and then is able to generate a diff --git a/sphinx/ext/intersphinx.py b/sphinx/ext/intersphinx.py index 2c9a461bd..ac1ec9bc9 100644 --- a/sphinx/ext/intersphinx.py +++ b/sphinx/ext/intersphinx.py @@ -58,7 +58,7 @@ if False: logger = logging.getLogger(__name__) -class InventoryAdapter(object): +class InventoryAdapter: """Inventory adapter for environment""" def __init__(self, env): @@ -387,11 +387,11 @@ def inspect_main(argv): file=sys.stderr) sys.exit(1) - class MockConfig(object): + class MockConfig: intersphinx_timeout = None # type: int tls_verify = False - class MockApp(object): + class MockApp: srcdir = '' config = MockConfig() diff --git a/sphinx/ext/napoleon/__init__.py b/sphinx/ext/napoleon/__init__.py index b968f5948..f8b358463 100644 --- a/sphinx/ext/napoleon/__init__.py +++ b/sphinx/ext/napoleon/__init__.py @@ -22,7 +22,7 @@ if False: from typing import Any, Dict, List # NOQA -class Config(object): +class Config: """Sphinx napoleon extension settings in `conf.py`. Listed below are all the settings used by napoleon and their default diff --git a/sphinx/ext/napoleon/iterators.py b/sphinx/ext/napoleon/iterators.py index 8926c865c..0ad8038f3 100644 --- a/sphinx/ext/napoleon/iterators.py +++ b/sphinx/ext/napoleon/iterators.py @@ -18,7 +18,7 @@ if False: from typing import Any, Iterable # NOQA -class peek_iter(object): +class peek_iter: """An iterator object that supports peeking ahead. Parameters diff --git a/sphinx/extension.py b/sphinx/extension.py index 732ea327c..2bb38abe5 100644 --- a/sphinx/extension.py +++ b/sphinx/extension.py @@ -24,7 +24,7 @@ if False: logger = logging.getLogger(__name__) -class Extension(object): +class Extension: def __init__(self, name, module, **kwargs): # type: (unicode, Any, Any) -> None self.name = name diff --git a/sphinx/highlighting.py b/sphinx/highlighting.py index b344dc16b..1775f8ddb 100644 --- a/sphinx/highlighting.py +++ b/sphinx/highlighting.py @@ -62,7 +62,7 @@ _LATEX_ADD_STYLES = r''' ''' -class PygmentsBridge(object): +class PygmentsBridge: # Set these attributes if you want to have different Pygments formatters # than the default ones. html_formatter = HtmlFormatter diff --git a/sphinx/jinja2glue.py b/sphinx/jinja2glue.py index f19454c27..c3ed86e09 100644 --- a/sphinx/jinja2glue.py +++ b/sphinx/jinja2glue.py @@ -98,7 +98,7 @@ def accesskey(context, key): return '' -class idgen(object): +class idgen: def __init__(self): # type: () -> None self.id = 0 diff --git a/sphinx/locale/__init__.py b/sphinx/locale/__init__.py index 5c2caea9b..32eee44d1 100644 --- a/sphinx/locale/__init__.py +++ b/sphinx/locale/__init__.py @@ -25,7 +25,7 @@ if False: from typing import Any, Callable, Dict, Iterator, List, Tuple # NOQA -class _TranslationProxy(UserString, object): +class _TranslationProxy(UserString): """ Class for proxy strings from gettext translations. This is a helper for the lazy_* functions from this module. @@ -36,7 +36,6 @@ class _TranslationProxy(UserString, object): This inherits from UserString because some docutils versions use UserString for their Text nodes, which then checks its argument for being either a basestring or UserString, otherwise calls str() -- not unicode() -- on it. - This also inherits from object to make the __new__ method work. """ __slots__ = ('_func', '_args') diff --git a/sphinx/pycode/__init__.py b/sphinx/pycode/__init__.py index a97903a27..ce04f1d94 100644 --- a/sphinx/pycode/__init__.py +++ b/sphinx/pycode/__init__.py @@ -24,7 +24,7 @@ if False: from typing import Any, Dict, IO, List, Tuple # NOQA -class ModuleAnalyzer(object): +class ModuleAnalyzer: # cache for analyzer objects -- caches both by module and file name cache = {} # type: Dict[Tuple[unicode, unicode], Any] diff --git a/sphinx/pycode/parser.py b/sphinx/pycode/parser.py index 9d464a253..ca0143f55 100644 --- a/sphinx/pycode/parser.py +++ b/sphinx/pycode/parser.py @@ -107,7 +107,7 @@ def dedent_docstring(s): return docstring.lstrip("\r\n").rstrip("\r\n") -class Token(object): +class Token: """Better token wrapper for tokenize module.""" def __init__(self, kind, value, start, end, source): @@ -145,7 +145,7 @@ class Token(object): self.value.strip()) -class TokenProcessor(object): +class TokenProcessor: def __init__(self, buffers): # type: (List[unicode]) -> None lines = iter(buffers) @@ -464,7 +464,7 @@ class DefinitionFinder(TokenProcessor): self.context.pop() -class Parser(object): +class Parser: """Python source code parser to pick up variable comments. This is a better wrapper for ``VariableCommentPicker``. diff --git a/sphinx/registry.py b/sphinx/registry.py index 416edb2bc..132d1d207 100644 --- a/sphinx/registry.py +++ b/sphinx/registry.py @@ -54,7 +54,7 @@ EXTENSION_BLACKLIST = { } # type: Dict[unicode, unicode] -class SphinxComponentRegistry(object): +class SphinxComponentRegistry: def __init__(self): # type: () -> None #: special attrgetter for autodoc; class object -> attrgetter diff --git a/sphinx/roles.py b/sphinx/roles.py index 453eb5aa0..457c7465a 100644 --- a/sphinx/roles.py +++ b/sphinx/roles.py @@ -45,7 +45,7 @@ generic_docroles = { # -- generic cross-reference role ---------------------------------------------- -class XRefRole(object): +class XRefRole: """ A generic cross-referencing role. To create a callable that can be used as a role function, create an instance of this class. diff --git a/sphinx/search/__init__.py b/sphinx/search/__init__.py index 1c5d0a848..bf858c646 100644 --- a/sphinx/search/__init__.py +++ b/sphinx/search/__init__.py @@ -28,7 +28,7 @@ if False: from sphinx.environment import BuildEnvironment # NOQA -class SearchLanguage(object): +class SearchLanguage: """ This class is the base class for search natural language preprocessors. If you want to add support for a new language, you should override the methods @@ -155,7 +155,7 @@ languages = { } # type: Dict[unicode, Any] -class _JavaScriptIndex(object): +class _JavaScriptIndex: """ The search index as javascript file that calls a function on the documentation search object to register the index. @@ -236,7 +236,7 @@ class WordCollector(NodeVisitor): self.found_words.extend(keywords) -class IndexBuilder(object): +class IndexBuilder: """ Helper class that creates a searchindex based on the doctrees passed to the `feed` method. diff --git a/sphinx/search/ja.py b/sphinx/search/ja.py index a48a0df69..6eb972f4f 100644 --- a/sphinx/search/ja.py +++ b/sphinx/search/ja.py @@ -46,7 +46,7 @@ if False: from typing import Any, Dict, List # NOQA -class BaseSplitter(object): +class BaseSplitter: def __init__(self, options): # type: (Dict) -> None diff --git a/sphinx/testing/fixtures.py b/sphinx/testing/fixtures.py index fcf1028fd..4ea634b10 100644 --- a/sphinx/testing/fixtures.py +++ b/sphinx/testing/fixtures.py @@ -173,7 +173,7 @@ def make_app(test_params, monkeypatch): app_.cleanup() -class SharedResult(object): +class SharedResult: cache = {} # type: Dict[str, Dict[str, str]] def store(self, key, app_): diff --git a/sphinx/testing/util.py b/sphinx/testing/util.py index 2e0f6eb4d..ca0efefd5 100644 --- a/sphinx/testing/util.py +++ b/sphinx/testing/util.py @@ -92,7 +92,7 @@ def etree_parse(path): return ElementTree.parse(path) # type: ignore -class Struct(object): +class Struct: def __init__(self, **kwds): # type: (Any) -> None self.__dict__.update(kwds) @@ -163,7 +163,7 @@ class SphinxTestApp(application.Sphinx): return '<%s buildername=%r>' % (self.__class__.__name__, self.builder.name) -class SphinxTestAppWrapperForSkipBuilding(object): +class SphinxTestAppWrapperForSkipBuilding: """ This class is a wrapper for SphinxTestApp to speed up the test by skipping `app.build` process if it is already built and there is even one output diff --git a/sphinx/theming.py b/sphinx/theming.py index 938f2ede2..8a389c767 100644 --- a/sphinx/theming.py +++ b/sphinx/theming.py @@ -51,7 +51,7 @@ def extract_zip(filename, targetdir): fp.write(archive.read(name)) -class Theme(object): +class Theme: """A Theme is a set of HTML templates and configurations. This class supports both theme directory and theme archive (zipped theme).""" @@ -159,7 +159,7 @@ def is_archived_theme(filename): return False -class HTMLThemeFactory(object): +class HTMLThemeFactory: """A factory class for HTML Themes.""" def __init__(self, app): diff --git a/sphinx/util/__init__.py b/sphinx/util/__init__.py index 0c0c22c9c..ee584509f 100644 --- a/sphinx/util/__init__.py +++ b/sphinx/util/__init__.py @@ -403,7 +403,7 @@ def detect_encoding(readline): # Low-level utility functions and classes. -class Tee(object): +class Tee: """ File-like object writing to two streams. """ @@ -535,7 +535,7 @@ def format_exception_cut_frames(x=1): return ''.join(res) -class PeekableIterator(object): +class PeekableIterator: """ An iterator which wraps any iterable and makes it possible to peek to see what's the next item. diff --git a/sphinx/util/docfields.py b/sphinx/util/docfields.py index 202616337..1140c5457 100644 --- a/sphinx/util/docfields.py +++ b/sphinx/util/docfields.py @@ -36,7 +36,7 @@ def _is_single_paragraph(node): return False -class Field(object): +class Field: """A doc field that is never grouped. It can have an argument or not, the argument can be linked using a specified *rolename*. Field should be used for doc fields that usually don't occur more than once. @@ -235,7 +235,7 @@ class TypedField(GroupedField): return nodes.field('', fieldname, fieldbody) -class DocFieldTransformer(object): +class DocFieldTransformer: """ Transforms field lists in "doc field" syntax into better-looking equivalents, using the field type definitions given on a domain. diff --git a/sphinx/util/docutils.py b/sphinx/util/docutils.py index 547d74c17..3d957767b 100644 --- a/sphinx/util/docutils.py +++ b/sphinx/util/docutils.py @@ -148,7 +148,7 @@ class ElementLookupError(Exception): pass -class sphinx_domains(object): +class sphinx_domains: """Monkey-patch directive and role dispatch, so that domain-specific markup takes precedence. """ @@ -223,7 +223,7 @@ class sphinx_domains(object): return self.role_func(name, lang_module, lineno, reporter) -class WarningStream(object): +class WarningStream: def write(self, text): # type: (unicode) -> None matched = report_re.search(text) # type: ignore diff --git a/sphinx/util/inspect.py b/sphinx/util/inspect.py index 1c38caa25..211703e07 100644 --- a/sphinx/util/inspect.py +++ b/sphinx/util/inspect.py @@ -317,7 +317,7 @@ def is_builtin_class_method(obj, attr_name): return getattr(builtins, safe_getattr(cls, '__name__', '')) is cls # type: ignore -class Parameter(object): +class Parameter: """Fake parameter class for python2.""" POSITIONAL_ONLY = 0 POSITIONAL_OR_KEYWORD = 1 @@ -334,7 +334,7 @@ class Parameter(object): self.annotation = self.empty -class Signature(object): +class Signature: """The Signature object represents the call signature of a callable object and its return annotation. """ diff --git a/sphinx/util/inventory.py b/sphinx/util/inventory.py index ed4e55bc2..29bd872a7 100644 --- a/sphinx/util/inventory.py +++ b/sphinx/util/inventory.py @@ -32,7 +32,7 @@ BUFSIZE = 16 * 1024 logger = logging.getLogger(__name__) -class InventoryFileReader(object): +class InventoryFileReader: """A file reader for inventory file. This reader supports mixture of texts and compressed texts. @@ -94,7 +94,7 @@ class InventoryFileReader(object): pos = buf.find(b'\n') -class InventoryFile(object): +class InventoryFile: @classmethod def load(cls, stream, uri, joinfunc): # type: (IO, unicode, Callable) -> Inventory diff --git a/sphinx/util/logging.py b/sphinx/util/logging.py index 9e7c7ec9b..0875a8f5c 100644 --- a/sphinx/util/logging.py +++ b/sphinx/util/logging.py @@ -315,7 +315,7 @@ def skip_warningiserror(skip=True): handler.removeFilter(disabler) -class LogCollector(object): +class LogCollector: def __init__(self): # type: () -> None self.logs = [] # type: List[logging.LogRecord] @@ -495,7 +495,7 @@ class ColorizeFormatter(logging.Formatter): return message -class SafeEncodingWriter(object): +class SafeEncodingWriter: """Stream writer which ignores UnicodeEncodeError silently""" def __init__(self, stream): # type: (IO) -> None @@ -517,7 +517,7 @@ class SafeEncodingWriter(object): self.stream.flush() -class LastMessagesWriter(object): +class LastMessagesWriter: """Stream writer which memories last 10 messages to save trackback""" def __init__(self, app, stream): # type: (Sphinx, IO) -> None diff --git a/sphinx/util/matching.py b/sphinx/util/matching.py index bddf84f5c..43e68949a 100644 --- a/sphinx/util/matching.py +++ b/sphinx/util/matching.py @@ -68,7 +68,7 @@ def compile_matchers(patterns): return [re.compile(_translate_pattern(pat)).match for pat in patterns] -class Matcher(object): +class Matcher: """A pattern matcher for Multiple shell-style glob patterns. Note: this modifies the patterns to work with copy_asset(). diff --git a/sphinx/util/nodes.py b/sphinx/util/nodes.py index 9d500de76..78cd34f46 100644 --- a/sphinx/util/nodes.py +++ b/sphinx/util/nodes.py @@ -34,7 +34,7 @@ explicit_title_re = re.compile(r'^(.+?)\s*(?<!\x00)<(.*?)>$', re.DOTALL) caption_ref_re = explicit_title_re # b/w compat alias -class NodeMatcher(object): +class NodeMatcher: """A helper class for Node.traverse(). It checks that given node is an instance of specified node-classes and it has diff --git a/sphinx/util/osutil.py b/sphinx/util/osutil.py index ab56d749e..ab1cf4801 100644 --- a/sphinx/util/osutil.py +++ b/sphinx/util/osutil.py @@ -260,7 +260,7 @@ def cd(target_dir): os.chdir(cwd) -class FileAvoidWrite(object): +class FileAvoidWrite: """File-like object that buffers output and only writes if content changed. Use this class like when writing to a file to avoid touching the original diff --git a/sphinx/util/parallel.py b/sphinx/util/parallel.py index 066e3c93a..95ebc1406 100644 --- a/sphinx/util/parallel.py +++ b/sphinx/util/parallel.py @@ -36,7 +36,7 @@ logger = logging.getLogger(__name__) parallel_available = multiprocessing and (os.name == 'posix') -class SerialTasks(object): +class SerialTasks: """Has the same interface as ParallelTasks, but executes tasks directly.""" def __init__(self, nproc=1): @@ -57,7 +57,7 @@ class SerialTasks(object): pass -class ParallelTasks(object): +class ParallelTasks: """Executes *nproc* tasks in parallel after forking.""" def __init__(self, nproc): diff --git a/sphinx/util/pycompat.py b/sphinx/util/pycompat.py index 8bcf7e4f8..dc5a666b7 100644 --- a/sphinx/util/pycompat.py +++ b/sphinx/util/pycompat.py @@ -91,14 +91,14 @@ else: # UnicodeMixin if PY3: - class UnicodeMixin(object): + class UnicodeMixin: """Mixin class to handle defining the proper __str__/__unicode__ methods in Python 2 or 3.""" def __str__(self): return self.__unicode__() else: - class UnicodeMixin(object): + class UnicodeMixin: """Mixin class to handle defining the proper __str__/__unicode__ methods in Python 2 or 3.""" diff --git a/sphinx/util/stemmer/__init__.py b/sphinx/util/stemmer/__init__.py index a10da7370..43aef5032 100644 --- a/sphinx/util/stemmer/__init__.py +++ b/sphinx/util/stemmer/__init__.py @@ -18,7 +18,7 @@ except ImportError: PYSTEMMER = False -class BaseStemmer(object): +class BaseStemmer: def stem(self, word): # type: (unicode) -> unicode raise NotImplementedError() diff --git a/sphinx/util/stemmer/porter.py b/sphinx/util/stemmer/porter.py index beb860c9e..05abac644 100644 --- a/sphinx/util/stemmer/porter.py +++ b/sphinx/util/stemmer/porter.py @@ -29,7 +29,7 @@ """ -class PorterStemmer(object): +class PorterStemmer: def __init__(self): # type: () -> None diff --git a/sphinx/util/tags.py b/sphinx/util/tags.py index 43a351f65..4d0dc7f9a 100644 --- a/sphinx/util/tags.py +++ b/sphinx/util/tags.py @@ -46,7 +46,7 @@ class BooleanParser(Parser): return node -class Tags(object): +class Tags: def __init__(self, tags=None): # type: (List[unicode]) -> None self.tags = dict.fromkeys(tags or [], True) diff --git a/sphinx/util/template.py b/sphinx/util/template.py index 5a415d329..970b20177 100644 --- a/sphinx/util/template.py +++ b/sphinx/util/template.py @@ -23,7 +23,7 @@ if False: from jinja2.loaders import BaseLoader # NOQA -class BaseRenderer(object): +class BaseRenderer: def __init__(self, loader=None): # type: (BaseLoader) -> None self.env = SandboxedEnvironment(loader=loader, extensions=['jinja2.ext.i18n']) diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index cd222f1c7..0f1353be8 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -265,7 +265,7 @@ class ExtBabel(Babel): return None -class Table(object): +class Table: """A table data""" def __init__(self, node): @@ -386,7 +386,7 @@ class Table(object): return None -class TableCell(object): +class TableCell: """A cell data of tables.""" def __init__(self, table, row, col): diff --git a/sphinx/writers/manpage.py b/sphinx/writers/manpage.py index 4b6394e9a..471e58813 100644 --- a/sphinx/writers/manpage.py +++ b/sphinx/writers/manpage.py @@ -45,7 +45,7 @@ class ManualPageWriter(Writer): self.output = visitor.astext() -class NestedInlineTransform(object): +class NestedInlineTransform: """ Flatten nested inline nodes: diff --git a/tests/py35/test_autodoc_py35.py b/tests/py35/test_autodoc_py35.py index 5064970e6..39df5fcf4 100644 --- a/tests/py35/test_autodoc_py35.py +++ b/tests/py35/test_autodoc_py35.py @@ -247,7 +247,7 @@ class CustomEx(Exception): """Exception method.""" -class CustomDataDescriptor(object): +class CustomDataDescriptor: """Descriptor class docstring.""" def __init__(self, doc): @@ -275,7 +275,7 @@ def _funky_classmethod(name, b, c, d, docstring=None): return classmethod(function) -class Base(object): +class Base: def inheritedmeth(self): """Inherited function.""" diff --git a/tests/test_autodoc.py b/tests/test_autodoc.py index 2699bb181..2681e7c48 100644 --- a/tests/test_autodoc.py +++ b/tests/test_autodoc.py @@ -216,7 +216,7 @@ def test_format_signature(): class D: pass - class E(object): + class E: pass # no signature for classes without __init__ for C in (D, E): @@ -226,7 +226,7 @@ def test_format_signature(): def __init__(self, a, b=None): pass - class G(F, object): + class G(F): pass for C in (F, G): assert formatsig('class', 'C', C, None, None) == '(a, b=None)' @@ -243,7 +243,7 @@ def test_format_signature(): some docstring for __init__. ''' - class G2(F2, object): + class G2(F2): pass assert formatsig('class', 'F2', F2, None, None) == \ @@ -399,7 +399,7 @@ def test_get_doc(): assert getdocl('class', E) == ['Class docstring', '', 'Init docstring'] # class does not have __init__ method - class F(object): + class F: """Class docstring""" # docstring in the __init__ method of base class will be discard @@ -413,7 +413,7 @@ def test_get_doc(): assert getdocl('class', F) == ['Class docstring'] # class has __init__ method with no docstring - class G(object): + class G: """Class docstring""" def __init__(self): pass diff --git a/tests/test_build_epub.py b/tests/test_build_epub.py index f9872f28c..0d45cd289 100644 --- a/tests/test_build_epub.py +++ b/tests/test_build_epub.py @@ -28,7 +28,7 @@ def runnable(command): return p.returncode == 0 -class EPUBElementTree(object): +class EPUBElementTree: """Test helper for content.opf and toc.ncx""" namespaces = { 'idpf': 'http://www.idpf.org/2007/opf', diff --git a/tests/test_config.py b/tests/test_config.py index 5dd05550c..4a0a557fe 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -218,7 +218,7 @@ def test_builtin_conf(app, status, warning): # example classes for type checking -class A(object): +class A: pass diff --git a/tests/test_domain_cpp.py b/tests/test_domain_cpp.py index b8856824b..a68cb008c 100644 --- a/tests/test_domain_cpp.py +++ b/tests/test_domain_cpp.py @@ -22,7 +22,7 @@ from sphinx.domains.cpp import Symbol, _max_id, _id_prefix def parse(name, string): - class Config(object): + class Config: cpp_id_attributes = ["id_attr"] cpp_paren_attributes = ["paren_attr"] parser = DefinitionParser(string, None, Config()) @@ -804,7 +804,7 @@ not found in `{test}` assert result, expect return set(result.group('classes').split()) - class RoleClasses(object): + class RoleClasses: """Collect the classes from the layout that was generated for a given role.""" def __init__(self, role, root, contents): diff --git a/tests/test_ext_napoleon.py b/tests/test_ext_napoleon.py index 31130ad54..fd7eb0b9f 100644 --- a/tests/test_ext_napoleon.py +++ b/tests/test_ext_napoleon.py @@ -37,7 +37,7 @@ def __special_undoc__(): pass -class SampleClass(object): +class SampleClass: def _private_doc(self): """SampleClass._private_doc.DOCSTRING""" pass diff --git a/tests/test_search.py b/tests/test_search.py index 886151831..96a74896f 100644 --- a/tests/test_search.py +++ b/tests/test_search.py @@ -22,7 +22,7 @@ from sphinx.util import jsdump DummyEnvironment = namedtuple('DummyEnvironment', ['version', 'domains']) -class DummyDomain(object): +class DummyDomain: def __init__(self, data): self.data = data self.object_types = {} diff --git a/tests/test_util_inspect.py b/tests/test_util_inspect.py index 7266d4bbf..721299255 100644 --- a/tests/test_util_inspect.py +++ b/tests/test_util_inspect.py @@ -206,7 +206,7 @@ def test_Signature_methods(): def test_Signature_partialmethod(): from functools import partialmethod - class Foo(object): + class Foo: def meth1(self, arg1, arg2, arg3=None, arg4=None): pass @@ -309,7 +309,7 @@ def test_Signature_annotations(): def test_safe_getattr_with_default(): - class Foo(object): + class Foo: def __getattr__(self, item): raise Exception @@ -321,7 +321,7 @@ def test_safe_getattr_with_default(): def test_safe_getattr_with_exception(): - class Foo(object): + class Foo: def __getattr__(self, item): raise Exception @@ -336,7 +336,7 @@ def test_safe_getattr_with_exception(): def test_safe_getattr_with_property_exception(): - class Foo(object): + class Foo: @property def bar(self): raise Exception @@ -352,7 +352,7 @@ def test_safe_getattr_with_property_exception(): def test_safe_getattr_with___dict___override(): - class Foo(object): + class Foo: @property def __dict__(self): raise Exception @@ -410,7 +410,7 @@ def test_frozenset_sorting_fallback(): def test_dict_customtype(): - class CustomType(object): + class CustomType: def __init__(self, value): self._value = value diff --git a/utils/bump_version.py b/utils/bump_version.py index 444eefe07..55da12551 100755 --- a/utils/bump_version.py +++ b/utils/bump_version.py @@ -84,7 +84,7 @@ def processing(message): print('done') -class Changes(object): +class Changes: def __init__(self, path): self.path = path self.fetch_version() |