[issue46333] ForwardRef.__eq__ does not respect module parameter

Ken Jin report at bugs.python.org
Wed Jan 12 09:04:25 EST 2022


Ken Jin <kenjin4096 at gmail.com> added the comment:

@Andreas
First of all, thanks for addressing my questions on the PR. I have one more question which I'll post here since it's not entirely related to your PR.

ForwardRef isn't meant to be explicitly instantiated by a user [1] (it's a typing internal class), so do you mind sharing what your current use case is please? My concern here is that exposing things in __repr__ would force us to keep `module` forever (I'm 100% fine with __eq__ and __hash__). After digging up the commit history, I now recall that the module parameter was used solely as a fix for ForwardRefs in different-module TypedDict (see GH-27017 or bpo-41249). It's not used anywhere else, so I don't know if your current use case was ever intended when the module parameter was added.

[1]: https://docs.python.org/3/library/typing.html#typing.ForwardRef

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46333>
_______________________________________


More information about the Python-bugs-list mailing list