Remove object inheritance

This commit is contained in:
Dave Halter
2020-07-25 18:20:56 +02:00
parent 3c3c0b54dc
commit dcc756a373
16 changed files with 24 additions and 24 deletions

View File

@@ -56,7 +56,7 @@ def pytest_generate_tests(metafunc):
metafunc.parametrize('version_ge_py38', sorted(ge38))
class NormalizerIssueCase(object):
class NormalizerIssueCase:
"""
Static Analysis cases lie in the static_analysis folder.
The tests also start with `#!`, like the goto_definition tests.
@@ -88,7 +88,7 @@ def pytest_configure(config):
#root.addHandler(ch)
class Checker():
class Checker:
def __init__(self, version, is_passing):
self.version = version
self._is_passing = is_passing

View File

@@ -102,7 +102,7 @@ def _get_cache_clear_lock(cache_path=None):
parser_cache: Dict[str, Any] = {}
class _NodeCacheItem(object):
class _NodeCacheItem:
def __init__(self, node, lines, change_time=None):
self.node = node
self.lines = lines

View File

@@ -1,7 +1,7 @@
import os
class FileIO(object):
class FileIO:
def __init__(self, path):
self.path = path

View File

@@ -105,7 +105,7 @@ class Normalizer(metaclass=_NormalizerMeta):
return decorator
class NormalizerConfig(object):
class NormalizerConfig:
normalizer_class = Normalizer
def create_normalizer(self, grammar):
@@ -115,7 +115,7 @@ class NormalizerConfig(object):
return self.normalizer_class(grammar, self)
class Issue(object):
class Issue:
def __init__(self, node, code, message):
self.code = code
"""
@@ -145,7 +145,7 @@ class Issue(object):
return '<%s: %s>' % (self.__class__.__name__, self.code)
class Rule(object):
class Rule:
code: int
message: str

View File

@@ -73,7 +73,7 @@ class Stack(list):
return list(iterate())
class StackNode(object):
class StackNode:
def __init__(self, dfa):
self.dfa = dfa
self.nodes = []
@@ -98,7 +98,7 @@ def _token_to_transition(grammar, type_, value):
return type_
class BaseParser(object):
class BaseParser:
"""Parser engine.
A Parser instance contains state pertaining to the current token

View File

@@ -247,7 +247,7 @@ def _update_positions(nodes, line_offset, last_leaf):
_update_positions(children, line_offset, last_leaf)
class DiffParser(object):
class DiffParser:
"""
An advanced form of parsing a file faster. Unfortunately comes with huge
side effects. It changes the given module.
@@ -514,7 +514,7 @@ class DiffParser(object):
yield token
class _NodesTreeNode(object):
class _NodesTreeNode:
_ChildrenGroup = namedtuple(
'_ChildrenGroup',
'prefix children line_offset last_line_offset_leaf')
@@ -589,7 +589,7 @@ class _NodesTreeNode(object):
return '<%s: %s>' % (self.__class__.__name__, self.tree_node)
class _NodesTree(object):
class _NodesTree:
def __init__(self, module):
self._base_node = _NodesTreeNode(module)
self._working_stack = [self._base_node]

View File

@@ -222,7 +222,7 @@ def _any_fstring_error(version, node):
return search_ancestor(node, "fstring")
class _Context(object):
class _Context:
def __init__(self, node, add_syntax_error, parent_context=None):
self.node = node
self.blocks = []

View File

@@ -26,7 +26,7 @@ _IMPLICIT_INDENTATION_TYPES = ('dictorsetmaker', 'argument')
_POSSIBLE_SLICE_PARENTS = ('subscript', 'subscriptlist', 'sliceop')
class IndentationTypes(object):
class IndentationTypes:
VERTICAL_BRACKET = object()
HANGING_BRACKET = object()
BACKSLASH = object()

View File

@@ -6,7 +6,7 @@ from parso.python.tokenize import group
unicode_bom = BOM_UTF8.decode('utf-8')
class PrefixPart(object):
class PrefixPart:
def __init__(self, leaf, typ, value, spacing='', start_pos=None):
assert start_pos is not None
self.parent = leaf

View File

@@ -3,7 +3,7 @@ from __future__ import absolute_import
from enum import Enum
class TokenType(object):
class TokenType:
name: str
contains_syntax: bool

View File

@@ -246,7 +246,7 @@ class PythonToken(Token):
self._replace(type=self.type.name))
class FStringNode(object):
class FStringNode:
def __init__(self, quote):
self.quote = quote
self.parentheses_count = 0

View File

@@ -68,7 +68,7 @@ _GET_DEFINITION_TYPES = set([
_IMPORTS = set(['import_name', 'import_from'])
class DocstringMixin(object):
class DocstringMixin:
__slots__ = ()
def get_doc_node(self):
@@ -96,7 +96,7 @@ class DocstringMixin(object):
return None
class PythonMixin(object):
class PythonMixin:
"""
Some Python specific utilities.
"""
@@ -296,7 +296,7 @@ class FStringEnd(PythonLeaf):
__slots__ = ()
class _StringComparisonMixin(object):
class _StringComparisonMixin:
def __eq__(self, other):
"""
Make comparisons with strings easy.

View File

@@ -18,7 +18,7 @@ def search_ancestor(node, *node_types):
return node
class NodeOrLeaf(object):
class NodeOrLeaf:
"""
The base class for nodes and leaves.
"""

View File

@@ -38,7 +38,7 @@ def _check_error_leaves_nodes(node):
return None
class Differ(object):
class Differ:
grammar = load_grammar()
def initialize(self, code):

View File

@@ -12,7 +12,7 @@ from parso.utils import python_bytes_to_unicode
@total_ordering
class WantedIssue(object):
class WantedIssue:
def __init__(self, code, line, column):
self.code = code
self._line = line

View File

@@ -8,7 +8,7 @@ from parso import parse
from parso.python import tree
class TestsFunctionAndLambdaParsing(object):
class TestsFunctionAndLambdaParsing:
FIXTURES = [
('def my_function(x, y, z) -> str:\n return x + y * z\n', {