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

Feedback for name2type mapping #5841

Closed
guettli opened this issue Oct 26, 2018 · 2 comments
Closed

Feedback for name2type mapping #5841

guettli opened this issue Oct 26, 2018 · 2 comments

Comments

@guettli
Copy link

guettli commented Oct 26, 2018

Dear mypy developers,

I am looking for feedback for this little idea:

https://github.com/guettli/python-name2type-mapping

Please tell me what you think.

Python name2type mapping

In October 2018 on the mailing list python-ideas some developers encouraged me, that the idea of a name2type mapping would be usefull.

Goal:

  • Better type-hints in IDEs.

This is not the goal:

  • Type-hints which get used during run-time.

Syntax Proposal

The name2type mapping is defined in the docstring of a Python file.

The general syntax is "name2type:" followed by a comma sperated list of variable names. Then ":", then the type hint.

Examples::

 """
 name2type: my_int, my_number, ....: int
 name2type: request*: django.http.HttpRequest
 """"

If the docstring is in a file called __init__.py, then the type hints get specified for all files below this directory (recursively).

@ilevkivskyi
Copy link
Member

I think this belongs rather to stubgen (maintained here), or to PyAnnotate (in a separate repo), rather than to mypy itself. Otherwise such feature might have some weird action at a distance. Also explicit is better than implicit.

@gvanrossum
Copy link
Member

Yeah, there is now a whole repo dedicated to discussion of this idea, no need to have a separate discussion in any of the mypy projects.

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

No branches or pull requests

3 participants