Describe the bug
The return value type hint for v_args() isn't fully correct
|
def v_args(inline: bool = False, meta: bool = False, tree: bool = False, wrapper: Optional[Callable] = None) -> Callable[[_DECORATED], _DECORATED]: |
When -> Callable[[_DECORATED], _DECORATED] is removed entirely, i.e. the line changed to:
def v_args(inline: bool = False, meta: bool = False, tree: bool = False, wrapper: Optional[Callable] = None):
my typechecker (pyright/basedpyright, i.e. pylance from VSCode) properly infers the return type of transform()
To Reproduce
from lark import Transformer, v_args, Token, Tree
@v_args(meta=True)
class Foo(Transformer[Token, str]):
def __init__(self):
super().__init__()
def foo(self, meta, args):
return 'baz'
bar = Foo().transform(Tree('foo', []))
assert bar == 'baz'
with -> Callable[[_DECORATED], _DECORATED], type inference breaks and bar is considered Any | Unknown
without, bar is correctly considered str
Describe the bug
The return value type hint for
v_args()isn't fully correctlark/lark/visitors.py
Line 513 in 52ef09d
When
-> Callable[[_DECORATED], _DECORATED]is removed entirely, i.e. the line changed to:my typechecker (pyright/basedpyright, i.e. pylance from VSCode) properly infers the return type of
transform()To Reproduce
with
-> Callable[[_DECORATED], _DECORATED], type inference breaks andbaris consideredAny | Unknownwithout,
baris correctly consideredstr