def capybara(): s = "x" b = b"x" assert_is_value(s.encode("ascii"), KnownValue(b"x")) assert_is_value(b.decode("ascii"), KnownValue("x")) s.encode("not an encoding") # E: incompatible_call
def capybara(x): l = hasattr(x, "foo") assert_is_value( l, AnnotatedValue( TypedValue(bool), [ HasAttrGuardExtension( "object", KnownValue("foo"), UNRESOLVED_VALUE ) ], ), )
def capybara() -> None: assert_is_value(mktemp(), UNRESOLVED_VALUE) assert_is_value(mktemp(prefix="p"), KnownValue("p")) assert_is_value(mktemp(suffix="s"), KnownValue("s"))
def capybara(x: Optional[int]): assert_is_value(x, MultiValuedValue([KnownValue(None), TypedValue(int)])) assert_is_value(assert_not_none(x), TypedValue(int))
def capybara(x: str, xs: List[int], gen: GenCls[int]) -> None: assert_is_value(id(3), KnownValue(3)) assert_is_value(id(x), TypedValue(str)) assert_is_value(get_one(xs), TypedValue(int)) assert_is_value(get_one([int(3)]), TypedValue(int)) # This one doesn't work yet because we don't know how to go from # KnownValue([3]) to a GenericValue of some sort. # assert_is_value(get_one([3]), KnownValue(3)) assert_is_value(gen.get_one(), TypedValue(int)) assert_is_value(gen.get_another(), TypedValue(int))
def capybara(): assert_is_value(A(), TypedValue(A)) assert_is_value( pyanalyze.tests.WhatIsMyName(), TypedValue(pyanalyze.tests.WhatIsMyName) )
def __init__(self) -> None: assert_is_value(self, TypedValue(A))
def fn(): capybara = int("3") assert_is_value(capybara, TypedValue(int))
def capybara(x): obj = WithCall() assert_is_value(obj, TypedValue(WithCall)) assert_is_value(obj(x), UNRESOLVED_VALUE)
def run(elts): lst = [x for x in elts] assert_is_value(lst, TypedValue(list)) lst()
def capybara(uid): assert_is_value(PropertyObject(uid).string_property, TypedValue(str))