Draft typing spec chapter for constructors

I feel like my ideal behavior (for both __call__ and __new__) would look something like:

  • no return type annotation: assume an instance of the class is returned
  • if annotated to return anything other than an instance of the class (including Any): something special is being done, don’t evaluate subsequent constructor methods

I agree with Eric’s point that this isn’t the time to try to introduce a full-blown Unknown type, but what about specifically special-casing constructor methods to have an assumed return type annotation when they’re left unannotated?

3 Likes