-
-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: API checks: Check for types compatibility #113
Comments
Moving this here from the README:
|
I wonder: could we somehow recurse into objects to check that they implement the same "protocols"? Example: class Foo:
def method1(self): ...
def method2(self, param1: int, param2: int): ...
class Bar:
def method2(self, param1: int, param2: int): ...
class Baz:
def method1(self): ...
def method2(self, param1: int): ...
class Qux:
def method1(self): ...
def method2(self, param1: str, param2: int): ...
class Quux:
def method1(self): ...
def method2(self, param1: int, param2: int): ...
def method3(self): ...
def f_old(param: Foo): ...
def f_new(param: Bar): ... # breaks: removed method1
def f_new(param: Baz): ... # breaks: removed param2 on method2
def f_new(param: Qux): ... # breaks: changed type of param1 on method2 (int -> str is a "known" breakage)
def f_new(param: Quux): ... # doesn't break: added method3 I imagine a |
Or maybe there's a way to hook into mypy... |
We would need to match protocols in all expression parts. In
To compare objects, we'd have to dynamically load external objects (but only if they weren't already used). Examples:
Or we could expect users to pre-load these modules and soft-fail otherwise. By the way, how to compare |
Following the discussion in #75, we released a first version of the API breakage detection feature, which does not check if types (parameters types, return types) are compatible between the old and new code.
This issue is here to discuss about adding support for checking types compatibility.
It's already possible at runtime with beartype, so maybe we could use in the inspector. But for the visitor we need something static.
Boost priority
The text was updated successfully, but these errors were encountered: