Summary
This code sample works with Mypy and fails on ty.
No additional configurations, only run: ty check
from typing import Callable
def _method(self: "Foo") -> "Foo":
return Foo()
def _method_wrapper(
) -> Callable[["Foo"], "Foo"]:
return _method
class Foo:
direct_assignment = _method
assign_via_wrapper = _method_wrapper()
def boo(c: Foo) -> None:
c.direct_assignment()
c.assign_via_wrapper()
# | ^^^^^^^^^^^^^^^^^^^^^^
# |
# info: Union variant `(Foo, /) -> Foo` is incompatible with this call site
# info: Attempted to call union type `Unknown | ((Foo, /) -> Foo)`
# info: rule `missing-argument` is enabled by default
The original problem was discovered when using PySpark 3.4 https://github.com/apache/spark/blob/branch-3.4/python/pyspark/sql/column.py#L1065
from pyspark.sql.column import Column
def foo(c: Column) -> Column:
return c.desc()
Version
0.0.8