Przeglądaj źródła

Add missing type hint for Token constructor

mypy thinks that Token's __init__ is inherited from __str__(). That's
not wrong -- it's just irrelevant, because Token also implements
__new__(). Token's _effective_ constructor signature is determined by
its __new__() method, so that's what I have used in the type hint.

Not clear if 'value' is supposed to be Any, but that's what I need in
my application. And it works just fine!
tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.11.2
Greg Ward 3 lat temu
rodzic
commit
68e5e86b5b
1 zmienionych plików z 3 dodań i 0 usunięć
  1. +3
    -0
      lark-stubs/lexer.pyi

+ 3
- 0
lark-stubs/lexer.pyi Wyświetl plik

@@ -85,6 +85,9 @@ class Token(str):
end_column: int
end_pos: int

def __init__(self, type_: str, value: Any, pos_in_stream: int = None, line: int = None, column: int = None, end_line: int = None, end_column: int = None, end_pos: int = None):
...

def update(self, type_: Optional[str] = None, value: Optional[str] = None) -> Token:
...



Ładowanie…
Anuluj
Zapisz