[issue27989] incomplete signature with help function using typing

2016-10-22 Thread Guido van Rossum
Guido van Rossum added the comment: Honestly I think pydoc is already too verbose. It would be better if the class header looked more like what was written in the source code -- that is the most compact way to render it. I say open a separate issue since this issue is about functions.

[issue27989] incomplete signature with help function using typing

2016-10-22 Thread Guido van Rossum
Changes by Guido van Rossum : -- resolution: -> fixed stage: -> resolved status: open -> closed ___ Python tracker ___

[issue27989] incomplete signature with help function using typing

2016-10-22 Thread Roundup Robot
Roundup Robot added the comment: New changeset dc030d15f80d by Guido van Rossum in branch '3.5': Issue #27989: Tweak inspect.formatannotation() to improve pydoc rendering of function annotations. Ivan L. https://hg.python.org/cpython/rev/dc030d15f80d New changeset 3937502c149d by Guido van

[issue27989] incomplete signature with help function using typing

2016-10-22 Thread Ivan Levkivskyi
Ivan Levkivskyi added the comment: Actually, for classes, it is probably worth adding a separate section "Generic type info" that will render information using __orig_bases__, __parameters__, and __args__. At the same time the "header" will be the same as now, listing runtime __bases__. What

[issue27989] incomplete signature with help function using typing

2016-10-22 Thread Guido van Rossum
Guido van Rossum added the comment: OK, sounds good then. I guess most of the work was in typing.py, not in inspect. :-) -- ___ Python tracker ___

[issue27989] incomplete signature with help function using typing

2016-10-22 Thread Ivan Levkivskyi
Ivan Levkivskyi added the comment: For function annotations I did as originally proposed. In my previous comment I was talking about documentation for classes. For example: class C(Generic[T], Mapping[int, str]): ... pydoc.render_doc(C) will show "class C(typing.Mapping)". while for function

[issue27989] incomplete signature with help function using typing

2016-10-22 Thread Guido van Rossum
Guido van Rossum added the comment: Hm, I actually like the original proposal better. Perhaps collections.abc.Mapping is more common than typing.Mapping, but is it more common *in function annotations*? I don't think so. Also, I like showing e.g. Iterator[Tuple[int, Any]] rather than just

[issue27989] incomplete signature with help function using typing

2016-10-22 Thread Ivan Levkivskyi
Ivan Levkivskyi added the comment: Here is the patch according to the discussion (modifying inspect). I didn't change the rendering of docs for classes (neither stripped 'typing.' nor changed __bases__ to __orig_bases__). First, collections.abc.X are widely used as base classes, so that plain

[issue27989] incomplete signature with help function using typing

2016-09-07 Thread David E. Franco G.
David E. Franco G. added the comment: I think that removing the "typing." is for the best, with the example above >>> help(foo) Help on function foo in module __main__: foo(data:typing.List[typing.Any]) -> typing.Iterator[typing.Tuple[int, typing.Any]] >>> leaving the "typing." produce

[issue27989] incomplete signature with help function using typing

2016-09-07 Thread Ivan Levkivskyi
Changes by Ivan Levkivskyi : -- nosy: +levkivskyi ___ Python tracker ___ ___

[issue27989] incomplete signature with help function using typing

2016-09-07 Thread Guido van Rossum
Guido van Rossum added the comment: I've lost you -- why don't you upload a patch? -- ___ Python tracker ___

[issue27989] incomplete signature with help function using typing

2016-09-07 Thread Spencer Brown
Spencer Brown added the comment: It might be better to just change the if statement to 'if isinstance(annotation, type) and type(annotation).__repr__ is type.__repr__:'. That would make it fallback for any metaclass which overrides repr, instead of special-casing typing. That also ensures

[issue27989] incomplete signature with help function using typing

2016-09-07 Thread Guido van Rossum
Guido van Rossum added the comment: That sounds a fine solution (except the elif should just test for `in 'typing'`). Can one of you prepare a patch? I think it should be fine to fix this in 3.5 as well. There should be a unit test for this. -- ___

[issue27989] incomplete signature with help function using typing

2016-09-07 Thread David E. Franco G.
David E. Franco G. added the comment: as that is the case, how about this as a solution: def formatannotation(annotation, base_module=None): if isinstance(annotation, type): if annotation.__module__ in ('builtins', base_module): return annotation.__qualname__

[issue27989] incomplete signature with help function using typing

2016-09-07 Thread Spencer Brown
Spencer Brown added the comment: More precisely, the issue is with inspect.formatannotation(), which overrides/ignores the repr if the annotation is an instance of type. Perhaps that should be changed to also check that __repr__ is type's repr. -- nosy: +Spencer Brown

[issue27989] incomplete signature with help function using typing

2016-09-06 Thread Guido van Rossum
Guido van Rossum added the comment: It seems the output produced here is generated by inspect.signature(), which is called by pydoc in this case (in both versions of docroutine()). I don't know if the right thing to do is to change inspect.signature() here, or to change pydoc to use something

[issue27989] incomplete signature with help function using typing

2016-09-06 Thread David E. Franco G.
New submission from David E. Franco G.: the issue is that when calling help on a function annotated with typing, all the relevant information is lost, for example from typing import List, Any, Iterator, Tuple def foo(data:List[Any]) -> Iterator[ Tuple[int,Any] ]: ... when calling help