Skip to content

Commit

Permalink
Fixes to mypy stubs (Issue lark-parser#561)
Browse files Browse the repository at this point in the history
  • Loading branch information
erezsh committed Apr 18, 2020
1 parent 227f5de commit f04a216
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ jobs:
python -m pip install --upgrade pip
pip install mypy
- name: Lint with mypy
run: mypy -m lark_stubs || true
run: mypy -p lark-stubs || true
File renamed without changes.
File renamed without changes.
File renamed without changes.
23 changes: 9 additions & 14 deletions lark_stubs/lark.pyi → lark-stubs/lark.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ from .lexer import Token, Lexer, TerminalDef
from .tree import Tree

_T = TypeVar('_T')
_Start = Union[None, str, List[str]]
_Parser = Literal["earley", "lalr", "cyk"]
_Lexer = Union[Literal["auto", "standard", "contextual", "dynamic", "dynamic_complete"], Lexer]
_Ambiguity = Literal["explicit", "resolve"]


class PostLex(Protocol):

Expand All @@ -22,12 +17,12 @@ class PostLex(Protocol):


class LarkOptions:
start: _Start
parser: _Parser
lexer: _Lexer
start: List[str]
parser: str
lexer: str
transformer: Optional[Transformer]
postlex: Optional[PostLex]
ambiguity: _Ambiguity
ambiguity: str
debug: bool
keep_all_tokens: bool
propagate_positions: bool
Expand All @@ -47,12 +42,12 @@ class Lark:
self,
grammar: Union[str, IO[str]],
*,
start: _Start = ...,
parser: _Parser = ...,
lexer: _Lexer = ...,
start: Union[None, str, List[str]] = "start",
parser: Literal["earley", "lalr", "cyk"] = "auto",
lexer: Union[Literal["auto", "standard", "contextual", "dynamic", "dynamic_complete"], Lexer] = "auto",
transformer: Optional[Transformer] = None,
postlex: Optional[PostLex] = None,
ambiguity: _Ambiguity = ...,
ambiguity: Literal["explicit", "resolve"] = "resolve",
debug: bool = False,
keep_all_tokens: bool = False,
propagate_positions: bool = False,
Expand All @@ -62,7 +57,7 @@ class Lark:
):
...

def parse(self, text: str, start: _Start = None) -> Tree:
def parse(self, text: str, start: Optional[str] = None) -> Tree:
...

@classmethod
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
setup(
name = "lark-parser",
version = __version__,
packages = ['lark', 'lark.parsers', 'lark.tools', 'lark.grammars', 'lark_stubs'],
packages = ['lark', 'lark.parsers', 'lark.tools', 'lark.grammars', 'lark-stubs'],

requires = [],
install_requires = [],

package_data = {'': ['*.md', '*.lark'], 'lark_stubs': ['*.pyi']},
package_data = {'': ['*.md', '*.lark'], 'lark-stubs': ['*.pyi']},

test_suite = 'tests.__main__',

Expand Down

0 comments on commit f04a216

Please sign in to comment.