Skip to content

Commit

Permalink
Added draft chapter to typing spec for constructors. (#1667)
Browse files Browse the repository at this point in the history
* Added draft chapter to typing spec for constructors.

* Update docs/spec/constructors.rst

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>

* Update docs/spec/constructors.rst

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>

* Update docs/spec/constructors.rst

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>

* Added section on signature consistency between `__new__` and `__init__`.

* Incorporated PR feedback.

* Added clarification based on question in forum.

* Incorporated feedback about callable conversion. Clarified behaviors when a class doesn't inherit a `__new__` or `__init__` from a class other than `object`.

* Tweaked the spec based on Jelle's feedback about a `__new__` method that returns `Any`. Also clarified what happens when a call to `__call__` or `__new__` evaluates to a union type.

* Updated handling of `Any` return types for `__call__` and `__new__` methods to reflect suggestion from @rchen152 in [this post](https://discuss.python.org/t/draft-typing-spec-chapter-for-constructors/49744/22).

* Incorporated feedback from @gvanrossum.

---------

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
  • Loading branch information
erictraut and JelleZijlstra committed Apr 11, 2024
1 parent 8ff42d7 commit 1c3b7df
Show file tree
Hide file tree
Showing 2 changed files with 493 additions and 0 deletions.

0 comments on commit 1c3b7df

Please sign in to comment.