mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-06 21:04:29 +08:00
Remove super arguments
This commit is contained in:
@@ -38,7 +38,7 @@ class FileIO:
|
|||||||
|
|
||||||
class KnownContentFileIO(FileIO):
|
class KnownContentFileIO(FileIO):
|
||||||
def __init__(self, path, content):
|
def __init__(self, path, content):
|
||||||
super(KnownContentFileIO, self).__init__(path)
|
super().__init__(path)
|
||||||
self._content = content
|
self._content = content
|
||||||
|
|
||||||
def read(self):
|
def read(self):
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ class PythonGrammar(Grammar):
|
|||||||
_start_nonterminal = 'file_input'
|
_start_nonterminal = 'file_input'
|
||||||
|
|
||||||
def __init__(self, version_info: PythonVersionInfo, bnf_text: str):
|
def __init__(self, version_info: PythonVersionInfo, bnf_text: str):
|
||||||
super(PythonGrammar, self).__init__(
|
super().__init__(
|
||||||
bnf_text,
|
bnf_text,
|
||||||
tokenizer=self._tokenize_lines,
|
tokenizer=self._tokenize_lines,
|
||||||
parser=PythonParser,
|
parser=PythonParser,
|
||||||
|
|||||||
@@ -189,10 +189,10 @@ class RefactoringNormalizer(Normalizer):
|
|||||||
try:
|
try:
|
||||||
return self._node_to_str_map[node]
|
return self._node_to_str_map[node]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return super(RefactoringNormalizer, self).visit(node)
|
return super().visit(node)
|
||||||
|
|
||||||
def visit_leaf(self, leaf):
|
def visit_leaf(self, leaf):
|
||||||
try:
|
try:
|
||||||
return self._node_to_str_map[leaf]
|
return self._node_to_str_map[leaf]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return super(RefactoringNormalizer, self).visit_leaf(leaf)
|
return super().visit_leaf(leaf)
|
||||||
|
|||||||
@@ -350,7 +350,7 @@ class ErrorFinder(Normalizer):
|
|||||||
Searches for errors in the syntax tree.
|
Searches for errors in the syntax tree.
|
||||||
"""
|
"""
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(ErrorFinder, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self._error_dict = {}
|
self._error_dict = {}
|
||||||
self.version = self.grammar.version_info
|
self.version = self.grammar.version_info
|
||||||
|
|
||||||
@@ -374,7 +374,7 @@ class ErrorFinder(Normalizer):
|
|||||||
# might find errors in there that should be ignored, because
|
# might find errors in there that should be ignored, because
|
||||||
# the error node itself already shows that there's an issue.
|
# the error node itself already shows that there's an issue.
|
||||||
return ''
|
return ''
|
||||||
return super(ErrorFinder, self).visit(node)
|
return super().visit(node)
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def visit_node(self, node):
|
def visit_node(self, node):
|
||||||
@@ -439,7 +439,7 @@ class ErrorFinder(Normalizer):
|
|||||||
self.context = self.context.add_context(parent)
|
self.context = self.context.add_context(parent)
|
||||||
|
|
||||||
# The rest is rule based.
|
# The rest is rule based.
|
||||||
return super(ErrorFinder, self).visit_leaf(leaf)
|
return super().visit_leaf(leaf)
|
||||||
|
|
||||||
def _add_indentation_error(self, spacing, message):
|
def _add_indentation_error(self, spacing, message):
|
||||||
self.add_issue(spacing, 903, "IndentationError: " + message)
|
self.add_issue(spacing, 903, "IndentationError: " + message)
|
||||||
@@ -465,7 +465,7 @@ class IndentationRule(Rule):
|
|||||||
code = 903
|
code = 903
|
||||||
|
|
||||||
def _get_message(self, message, node):
|
def _get_message(self, message, node):
|
||||||
message = super(IndentationRule, self)._get_message(message, node)
|
message = super()._get_message(message, node)
|
||||||
return "IndentationError: " + message
|
return "IndentationError: " + message
|
||||||
|
|
||||||
|
|
||||||
@@ -490,7 +490,7 @@ class SyntaxRule(Rule):
|
|||||||
code = 901
|
code = 901
|
||||||
|
|
||||||
def _get_message(self, message, node):
|
def _get_message(self, message, node):
|
||||||
message = super(SyntaxRule, self)._get_message(message, node)
|
message = super()._get_message(message, node)
|
||||||
if (
|
if (
|
||||||
"f-string" not in message
|
"f-string" not in message
|
||||||
and _any_fstring_error(self._normalizer.version, node)
|
and _any_fstring_error(self._normalizer.version, node)
|
||||||
|
|||||||
@@ -61,8 +61,8 @@ class Parser(BaseParser):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, pgen_grammar, error_recovery=True, start_nonterminal='file_input'):
|
def __init__(self, pgen_grammar, error_recovery=True, start_nonterminal='file_input'):
|
||||||
super(Parser, self).__init__(pgen_grammar, start_nonterminal,
|
super().__init__(pgen_grammar, start_nonterminal,
|
||||||
error_recovery=error_recovery)
|
error_recovery=error_recovery)
|
||||||
|
|
||||||
self.syntax_errors = []
|
self.syntax_errors = []
|
||||||
self._omit_dedent_list = []
|
self._omit_dedent_list = []
|
||||||
@@ -75,7 +75,7 @@ class Parser(BaseParser):
|
|||||||
|
|
||||||
tokens = self._recovery_tokenize(tokens)
|
tokens = self._recovery_tokenize(tokens)
|
||||||
|
|
||||||
return super(Parser, self).parse(tokens)
|
return super().parse(tokens)
|
||||||
|
|
||||||
def convert_node(self, nonterminal, children):
|
def convert_node(self, nonterminal, children):
|
||||||
"""
|
"""
|
||||||
@@ -138,7 +138,7 @@ class Parser(BaseParser):
|
|||||||
return
|
return
|
||||||
|
|
||||||
if not self._error_recovery:
|
if not self._error_recovery:
|
||||||
return super(Parser, self).error_recovery(token)
|
return super().error_recovery(token)
|
||||||
|
|
||||||
def current_suite(stack):
|
def current_suite(stack):
|
||||||
# For now just discard everything that is not a suite or
|
# For now just discard everything that is not a suite or
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ class ImplicitNode(BracketNode):
|
|||||||
annotations and dict values.
|
annotations and dict values.
|
||||||
"""
|
"""
|
||||||
def __init__(self, config, leaf, parent):
|
def __init__(self, config, leaf, parent):
|
||||||
super(ImplicitNode, self).__init__(config, leaf, parent)
|
super().__init__(config, leaf, parent)
|
||||||
self.type = IndentationTypes.IMPLICIT
|
self.type = IndentationTypes.IMPLICIT
|
||||||
|
|
||||||
next_leaf = leaf.get_next_leaf()
|
next_leaf = leaf.get_next_leaf()
|
||||||
@@ -151,7 +151,7 @@ def _is_magic_name(name):
|
|||||||
|
|
||||||
class PEP8Normalizer(ErrorFinder):
|
class PEP8Normalizer(ErrorFinder):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(PEP8Normalizer, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self._previous_part = None
|
self._previous_part = None
|
||||||
self._previous_leaf = None
|
self._previous_leaf = None
|
||||||
self._on_newline = True
|
self._on_newline = True
|
||||||
@@ -174,7 +174,7 @@ class PEP8Normalizer(ErrorFinder):
|
|||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def visit_node(self, node):
|
def visit_node(self, node):
|
||||||
with super(PEP8Normalizer, self).visit_node(node):
|
with super().visit_node(node):
|
||||||
with self._visit_node(node):
|
with self._visit_node(node):
|
||||||
yield
|
yield
|
||||||
|
|
||||||
@@ -342,7 +342,7 @@ class PEP8Normalizer(ErrorFinder):
|
|||||||
self._newline_count = 0
|
self._newline_count = 0
|
||||||
|
|
||||||
def visit_leaf(self, leaf):
|
def visit_leaf(self, leaf):
|
||||||
super(PEP8Normalizer, self).visit_leaf(leaf)
|
super().visit_leaf(leaf)
|
||||||
for part in leaf._split_prefix():
|
for part in leaf._split_prefix():
|
||||||
if part.type == 'spacing':
|
if part.type == 'spacing':
|
||||||
# This part is used for the part call after for.
|
# This part is used for the part call after for.
|
||||||
@@ -732,7 +732,7 @@ class PEP8Normalizer(ErrorFinder):
|
|||||||
return
|
return
|
||||||
if code in (901, 903):
|
if code in (901, 903):
|
||||||
# 901 and 903 are raised by the ErrorFinder.
|
# 901 and 903 are raised by the ErrorFinder.
|
||||||
super(PEP8Normalizer, self).add_issue(node, code, message)
|
super().add_issue(node, code, message)
|
||||||
else:
|
else:
|
||||||
# Skip ErrorFinder here, because it has custom behavior.
|
# Skip ErrorFinder here, because it has custom behavior.
|
||||||
super(ErrorFinder, self).add_issue(node, code, message)
|
super(ErrorFinder, self).add_issue(node, code, message)
|
||||||
|
|||||||
@@ -330,7 +330,7 @@ class Scope(PythonBaseNode, DocstringMixin):
|
|||||||
__slots__ = ()
|
__slots__ = ()
|
||||||
|
|
||||||
def __init__(self, children):
|
def __init__(self, children):
|
||||||
super(Scope, self).__init__(children)
|
super().__init__(children)
|
||||||
|
|
||||||
def iter_funcdefs(self):
|
def iter_funcdefs(self):
|
||||||
"""
|
"""
|
||||||
@@ -386,7 +386,7 @@ class Module(Scope):
|
|||||||
type = 'file_input'
|
type = 'file_input'
|
||||||
|
|
||||||
def __init__(self, children):
|
def __init__(self, children):
|
||||||
super(Module, self).__init__(children)
|
super().__init__(children)
|
||||||
self._used_names = None
|
self._used_names = None
|
||||||
|
|
||||||
def _iter_future_import_names(self):
|
def _iter_future_import_names(self):
|
||||||
@@ -470,7 +470,7 @@ class Class(ClassOrFunc):
|
|||||||
__slots__ = ()
|
__slots__ = ()
|
||||||
|
|
||||||
def __init__(self, children):
|
def __init__(self, children):
|
||||||
super(Class, self).__init__(children)
|
super().__init__(children)
|
||||||
|
|
||||||
def get_super_arglist(self):
|
def get_super_arglist(self):
|
||||||
"""
|
"""
|
||||||
@@ -548,7 +548,7 @@ class Function(ClassOrFunc):
|
|||||||
type = 'funcdef'
|
type = 'funcdef'
|
||||||
|
|
||||||
def __init__(self, children):
|
def __init__(self, children):
|
||||||
super(Function, self).__init__(children)
|
super().__init__(children)
|
||||||
parameters = self.children[2] # After `def foo`
|
parameters = self.children[2] # After `def foo`
|
||||||
parameters.children[1:-1] = _create_params(parameters, parameters.children[1:-1])
|
parameters.children[1:-1] = _create_params(parameters, parameters.children[1:-1])
|
||||||
|
|
||||||
@@ -1075,7 +1075,7 @@ class Param(PythonBaseNode):
|
|||||||
type = 'param'
|
type = 'param'
|
||||||
|
|
||||||
def __init__(self, children, parent):
|
def __init__(self, children, parent):
|
||||||
super(Param, self).__init__(children)
|
super().__init__(children)
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
for child in children:
|
for child in children:
|
||||||
child.parent = self
|
child.parent = self
|
||||||
@@ -1175,7 +1175,7 @@ class Param(PythonBaseNode):
|
|||||||
:param include_comma bool: If enabled includes the comma in the string output.
|
:param include_comma bool: If enabled includes the comma in the string output.
|
||||||
"""
|
"""
|
||||||
if include_comma:
|
if include_comma:
|
||||||
return super(Param, self).get_code(include_prefix)
|
return super().get_code(include_prefix)
|
||||||
|
|
||||||
children = self.children
|
children = self.children
|
||||||
if children[-1] == ',':
|
if children[-1] == ',':
|
||||||
|
|||||||
@@ -247,7 +247,7 @@ class TypedLeaf(Leaf):
|
|||||||
__slots__ = ('type',)
|
__slots__ = ('type',)
|
||||||
|
|
||||||
def __init__(self, type, value, start_pos, prefix=''):
|
def __init__(self, type, value, start_pos, prefix=''):
|
||||||
super(TypedLeaf, self).__init__(value, start_pos, prefix)
|
super().__init__(value, start_pos, prefix)
|
||||||
self.type = type
|
self.type = type
|
||||||
|
|
||||||
|
|
||||||
@@ -339,7 +339,7 @@ class Node(BaseNode):
|
|||||||
__slots__ = ('type',)
|
__slots__ = ('type',)
|
||||||
|
|
||||||
def __init__(self, type, children):
|
def __init__(self, type, children):
|
||||||
super(Node, self).__init__(children)
|
super().__init__(children)
|
||||||
self.type = type
|
self.type = type
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
@@ -365,7 +365,7 @@ class ErrorLeaf(Leaf):
|
|||||||
type = 'error_leaf'
|
type = 'error_leaf'
|
||||||
|
|
||||||
def __init__(self, token_type, value, start_pos, prefix=''):
|
def __init__(self, token_type, value, start_pos, prefix=''):
|
||||||
super(ErrorLeaf, self).__init__(value, start_pos, prefix)
|
super().__init__(value, start_pos, prefix)
|
||||||
self.token_type = token_type
|
self.token_type = token_type
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ class PythonVersionInfo(_PythonVersionInfo):
|
|||||||
if len(other) != 2:
|
if len(other) != 2:
|
||||||
raise ValueError("Can only compare to tuples of length 2.")
|
raise ValueError("Can only compare to tuples of length 2.")
|
||||||
return (self.major, self.minor) > other
|
return (self.major, self.minor) > other
|
||||||
super(PythonVersionInfo, self).__gt__(other)
|
super().__gt__(other)
|
||||||
|
|
||||||
return (self.major, self.minor)
|
return (self.major, self.minor)
|
||||||
|
|
||||||
@@ -153,7 +153,7 @@ class PythonVersionInfo(_PythonVersionInfo):
|
|||||||
if len(other) != 2:
|
if len(other) != 2:
|
||||||
raise ValueError("Can only compare to tuples of length 2.")
|
raise ValueError("Can only compare to tuples of length 2.")
|
||||||
return (self.major, self.minor) == other
|
return (self.major, self.minor) == other
|
||||||
super(PythonVersionInfo, self).__eq__(other)
|
super().__eq__(other)
|
||||||
|
|
||||||
def __ne__(self, other):
|
def __ne__(self, other):
|
||||||
return not self.__eq__(other)
|
return not self.__eq__(other)
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ def test_cache_limit():
|
|||||||
|
|
||||||
class _FixedTimeFileIO(file_io.KnownContentFileIO):
|
class _FixedTimeFileIO(file_io.KnownContentFileIO):
|
||||||
def __init__(self, path, content, last_modified):
|
def __init__(self, path, content, last_modified):
|
||||||
super(_FixedTimeFileIO, self).__init__(path, content)
|
super().__init__(path, content)
|
||||||
self._last_modified = last_modified
|
self._last_modified = last_modified
|
||||||
|
|
||||||
def get_last_modified(self):
|
def get_last_modified(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user