C2121
C2121

Reputation: 91

Make Python 3.6+ Code in Compatible with Python 3.3

Here is a part of code (Parso) in Python 3.6:

class BaseParser:
"""Parser engine.
A Parser instance contains state pertaining to the current token
sequence, and should not be used concurrently by different threads
to parse separate token sequences.
See python/tokenize.py for how to get input tokens by a string.
When a syntax error occurs, error_recovery() is called.
"""

node_map: Dict[str, type] = {}
default_node = tree.Node

leaf_map: Dict[str, type] = {}
default_leaf = tree.Leaf

def __init__(self, pgen_grammar, start_nonterminal='file_input', error_recovery=False):
    self._pgen_grammar = pgen_grammar
    self._start_nonterminal = start_nonterminal
    self._error_recovery = error_recovery

How can I make it compatible with Python 3.3? What is the usage of leaf_map: Dict[str, type] = {}? Can I remove it?

Upvotes: 0

Views: 44

Answers (1)

balderman
balderman

Reputation: 23815

Dict[str, type] is python type annotations. It has no impact in runtime and can be removed.

See https://docs.python.org/3/library/typing.html

Upvotes: 1

Related Questions