소스 검색

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 년 전
부모
커밋
68e5e86b5b
1개의 변경된 파일3개의 추가작업 그리고 0개의 파일을 삭제
  1. +3
    -0
      lark-stubs/lexer.pyi

+ 3
- 0
lark-stubs/lexer.pyi 파일 보기

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



불러오는 중...
취소
저장