typing: add type hints to mercurial/help.py
The way I ended up doing this here was to basically ignore the TYPE_CHECKING
guard and just import what is needed, and define aliases as needed. The only types that are quoted are the forward referenced ones. This seems to be how people generally add type hints, so I'm not sure why pycompat.py
is jumping through hoops to avoid just referencing typing.TYPE_CHECKING
.
If we do care about not importing typing symbols outside of the type checker, all of this stuff can be quoted. But that looks ugly IMO. Also, my understanding is that in py3.7+, you can from __future__ import annotations
, and then the undefined stuff in the annotation positions is ignored, so it doesn't have to be quoted. So this way gets us closer to that (and then maybe the typing
symbols can be guarded, which would be an easier change than cleaning up unneeded quotes).