-
Notifications
You must be signed in to change notification settings - Fork 37
Description
Has anyone figured out a way around this? I generally don't use NewType because I think it's not necessary in the majority of cases, but I ran across this weird behavior recently when I got curious about how sphinx would represent function signatures with NewType annotations:
Index = NewType('Index', int)
def child_ext_private_key(self, i: Index) -> 'ExtPrivateKey':
......leads to this weirdness:

Whereas doing things with a simple type alias:
Index = int
def child_ext_private_key(self, i: Index) -> 'ExtPrivateKey':
......behaves as expected:

I would expect sphinx to represent a NewType with the name of the type e.g. Index in this case. But, honestly, even that seems problematic. Someone reading the docs won't know what an Index is supposed to be even though it's just an int. Even if there was documentation on a typing module that's part of a package, it doesn't seem reasonable for people to have to look up what is meant by a NewType annotation whenever they want to understand the API of a method.