Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Annotate collections which are hard to infer types for #1069

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lark/lexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ def __init__(self, conf: 'LexerConf', states: Dict[str, Collection[str]], always
trad_conf = copy(conf)
trad_conf.terminals = terminals

lexer_by_tokens = {}
lexer_by_tokens: Dict[FrozenSet[str], BasicLexer] = {}
self.lexers = {}
for state, accepts in states.items():
key = frozenset(accepts)
Expand Down
6 changes: 3 additions & 3 deletions lark/load_grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -1067,8 +1067,8 @@ def __init__(self, global_keep_all_tokens: bool=False, import_paths: Optional[Li
self.import_paths = import_paths or []
self.used_files = used_files or {}

self._definitions = {}
self._ignore_names = []
self._definitions: Dict[str, Definition] = {}
self._ignore_names: List[str] = []

def _grammar_error(self, is_term, msg, *names):
args = {}
Expand Down Expand Up @@ -1210,7 +1210,7 @@ def _unpack_definition(self, tree, mangle):
def load_grammar(self, grammar_text: str, grammar_name: str="<?>", mangle: Optional[Callable[[str], str]]=None) -> None:
tree = _parse_grammar(grammar_text, grammar_name)

imports = {}
imports: Dict[Tuple[str, ...], Tuple[Optional[str], Dict[str, str]]] = {}
for stmt in tree.children:
if stmt.data == 'import':
dotted_path, base_path, aliases = self._unpack_import(stmt, grammar_name)
Expand Down