The following is currently an error:
def accepts_list_of_objects(xs: list[object]): ...
def f():
xs = ["foo"]
accepts_list_of_objects(xs) # Expected `list[object]`, found `list[str]`
This is because we currently only collect bidirectional context from a restricted set of syntactical constructs like method calls, for performance reasons.
After some recent performance improvements, it might be worth exploring this again. @ibraheemdev suggested that we might potentially want to exclude some builtins that are known to contribute no constraints. For example, len(xs) calls are frequent (and known to cause problems in previous attempts), but do not provide any context for the element type of xs.
The following is currently an error:
This is because we currently only collect bidirectional context from a restricted set of syntactical constructs like method calls, for performance reasons.
After some recent performance improvements, it might be worth exploring this again. @ibraheemdev suggested that we might potentially want to exclude some builtins that are known to contribute no constraints. For example,
len(xs)calls are frequent (and known to cause problems in previous attempts), but do not provide any context for the element type ofxs.