-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using NewType doesn't play nice with sphinx docs #50
Comments
I haven't seen that docs bug before (but that may just be because we haven't had such public API case documented anywhere or I haven't been paying attention) But on the actual case, I personally find an def child_ext_private_key(i: Index) -> PrivateKey:
...
def get_index_generated_out_of_whatever() -> Index:
... In that case, it could make sense to prevent usage of Doesn't sound like a strong case. Imho, a strong case for def get_speed_in_kmh() -> KmH:
...
def get_speed_in_mph() -> MpH:
...
def get_duration_denver_to_boulder(speed: MpH) -> Minutes:
...
def get_duration_hamburg_to_berlin(speed: KmH) -> Minutes:
... Let's ignore the questionable design choice to use localized units for the calculations based on the cities but what's setting the example apart from the |
@cburgdorf Nice, I agree. I've actually never used |
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 withNewType
annotations:...leads to this weirdness:

Whereas doing things with a simple type alias:
...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 anIndex
is supposed to be even though it's just anint
. Even if there was documentation on atyping
module that's part of a package, it doesn't seem reasonable for people to have to look up what is meant by aNewType
annotation whenever they want to understand the API of a method.The text was updated successfully, but these errors were encountered: