facebookincubator / cinder

Cinder is Meta's internal performance-oriented production version of CPython.
https://trycinder.com
Other
3.42k stars 122 forks source link

We allow dropping argument annotations, but not return annotations in static Python #48

Closed DinoV closed 2 years ago

DinoV commented 2 years ago

This code results in a compile time error:

class C:
    def f(self, a: int) -> int: pass

class D(C):
    def f(self, a: int): pass

But this code does not:

class C:
    def f(self, a: int) -> int: pass

class D(C):
    def f(self, a) -> int: pass

We should consistently require matching annotations.

DinoV commented 2 years ago

Actually this is fine, we are allowing a to take a less specific type, and disallowing returning a less specific type.