Browse Source

Fixes to mypy stubs (Issue #561)

tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.8.6
Erez Sh 5 years ago
parent
commit
f04a2167d6
10 changed files with 12 additions and 17 deletions
  1. +1
    -1
      .github/workflows/mypy.yml
  2. +0
    -0
      lark-stubs/__init__.pyi
  3. +0
    -0
      lark-stubs/exceptions.pyi
  4. +0
    -0
      lark-stubs/indenter.pyi
  5. +9
    -14
      lark-stubs/lark.pyi
  6. +0
    -0
      lark-stubs/lexer.pyi
  7. +0
    -0
      lark-stubs/reconstruct.pyi
  8. +0
    -0
      lark-stubs/tree.pyi
  9. +0
    -0
      lark-stubs/visitors.pyi
  10. +2
    -2
      setup.py

+ 1
- 1
.github/workflows/mypy.yml View File

@@ -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

lark_stubs/__init__.pyi → lark-stubs/__init__.pyi View File


lark_stubs/exceptions.pyi → lark-stubs/exceptions.pyi View File


lark_stubs/indenter.pyi → lark-stubs/indenter.pyi View File


lark_stubs/lark.pyi → lark-stubs/lark.pyi View File

@@ -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):

@@ -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
@@ -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,
@@ -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

lark_stubs/lexer.pyi → lark-stubs/lexer.pyi View File


lark_stubs/reconstruct.pyi → lark-stubs/reconstruct.pyi View File


lark_stubs/tree.pyi → lark-stubs/tree.pyi View File


lark_stubs/visitors.pyi → lark-stubs/visitors.pyi View File


+ 2
- 2
setup.py View File

@@ -6,12 +6,12 @@ __version__ ,= re.findall('__version__ = "(.*)"', open('lark/__init__.py').read(
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__',



Loading…
Cancel
Save