Skip to content
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

Chatty Init signature with mypy when using help magic #11403

Open
ocehugo opened this issue Oct 16, 2018 · 1 comment
Open

Chatty Init signature with mypy when using help magic #11403

ocehugo opened this issue Oct 16, 2018 · 1 comment

Comments

@ocehugo
Copy link

ocehugo commented Oct 16, 2018

Originally posted at python/mypy#5713. The init signature is too long, and should be shorter. Please advise if this is not the correct location for reporting this.

  • Please insert below the code you are checking with mypy,
from typing import Union

from mypy_extensions import TypedDict


class Orequest(TypedDict):
    origin: str


class Drequest(TypedDict):
    dest: str


Urequest = Union[Orequest, Drequest]


class Server(object):
    def __init__(self, adict: Urequest) -> None:
        pass
  • What is the actual behavior/output?
In [1]: from test import Server
In [2]: Server?
Init signature: Server(adict:Union[importlib._bootstrap.Orequest, importlib._bootstrap.Drequest]) -> None
Docstring:      <no docstring>
...
  • What is the behavior/output you expect?
In [2]: Server?
Init signature: Server(adict:Union[Orequest,Drequest]) -> None
Docstring:      <no docstring>
...
  • What are the versions of mypy and Python you are using?
    python 3.6.5
    ipython 6.4.0
    mypy 0.6

  • Do you see the same issue after installing mypy from Git master?
    Yes

  • What are the mypy flags you are using? (For example --strict-optional)
    None

I would expect a clean init signature, without the importlib._bootstrap.

The code works as expected if using the "help" function, but not with the "help magic".

@ocehugo ocehugo changed the title Chatty Init signature with mypy Chatty Init signature with mypy when using help magic Oct 16, 2018
@Carreau
Copy link
Member

Carreau commented Oct 17, 2018

Thanks, but that seem to be a Python issue, it is not limited to IPython:

$ python
Python 3.6.5 | packaged by conda-forge | (default, Apr  6 2018, 13:44:09)
[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from foo import Server
>>> import inspect
>>> inspect.signature(Server)
<Signature (adict:Union[importlib._bootstrap.Orequest, importlib._bootstrap.Drequest]) -> None>

So my guess is to move that to CPython.

Sorry for the bump across many projects, and thanks for the report, we can try to have a workaround here, but it would be nice to have a fix Upstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants