`Callable` isn't `FunctionType`
from typing import Callable
def x(f: Callable[[], None]):
f.__name__ # str
- Addressed in #415
gotta decide how to actually go about doing this since we both have different opinions on how features like this should be implemented.
ideally i would want the basedpyright implementation to be compatible with basedmypy's while also being backwards compatible for users that don't use either of our type checkers. but the basedmypy implementation changes the behavior of the stdlib types typing.Callable and types.FunctionType. imo this isnt the best approach because it messes up 3rd party libraries. for example in pytest-robotframework where its types need to be compatible with both basedmypy, basedpyright, pyright and mypy, we have already run into issues with the keyword decorator that don't seem to be solvable from the library developer's perspective
imo, the new "work properly" types should be defined in basedtyping with fallback aliases to the stdlib versions depending on your type checker:
# in the basedtyping module:
# (this is pseudocode, im not fully accross how these two types work)
if BASEDMYPY: # can be updated to `if BASEDMYPY or BASEDPYRIGHT`, once it has this feature
class Callable(Protocol):
def __call__(self, *args: Never, **kwargs: Never) -> object: ...
class FunctionType(Callable):
__name__: str
__qualname__: str
else:
Callable = typing.Callable
FunctionType = typing.Callable
(note that in my approach, type checkers that support the better versions of the types can then have an option to ban users from using the old ones, but the old ones will continue to work as they used to for the purpose of backwards compatibility)
this way, 3rd party libraries such as pytest-robotframework can declare support for these non-standard features without breaking support for users that don't use basedmypy/basedpyright
PS. this approach will also fix the stupidest part about Callable, which is that it's defined in collections.abc - a module that is completely 100% unrelated to that type