mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-06 04:44:29 +08:00
Remove object inheritance
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import os
|
||||
|
||||
|
||||
class FileIO(object):
|
||||
class FileIO:
|
||||
def __init__(self, path):
|
||||
self.path = path
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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 = []
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -3,7 +3,7 @@ from __future__ import absolute_import
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class TokenType(object):
|
||||
class TokenType:
|
||||
name: str
|
||||
contains_syntax: bool
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -18,7 +18,7 @@ def search_ancestor(node, *node_types):
|
||||
return node
|
||||
|
||||
|
||||
class NodeOrLeaf(object):
|
||||
class NodeOrLeaf:
|
||||
"""
|
||||
The base class for nodes and leaves.
|
||||
"""
|
||||
|
||||
@@ -38,7 +38,7 @@ def _check_error_leaves_nodes(node):
|
||||
return None
|
||||
|
||||
|
||||
class Differ(object):
|
||||
class Differ:
|
||||
grammar = load_grammar()
|
||||
|
||||
def initialize(self, code):
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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', {
|
||||
|
||||
Reference in New Issue
Block a user