Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > de.comp.lang.python > #5296

[Python-de] name2type mapping

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Thomas Güttler <guettliml@thomas-guettler.de>
Newsgroups de.comp.lang.python
Subject [Python-de] name2type mapping
Date Fri, 26 Oct 2018 09:53:22 +0200
Lines 52
Message-ID <mailman.296.1540540404.2799.python-de@python.org> (permalink)
References <54aef4d4-d183-2974-4374-8a6fc07aa9ad@thomas-guettler.de>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 8bit
X-Trace news.uni-berlin.de z7CEXqkEnMr+Nx4+BaXrWAwTRWbc9kM0e8AfKlsGJP4A==
Return-Path <guettliml@thomas-guettler.de>
X-Original-To python-de@python.org
Delivered-To python-de@mail.python.org
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1
Content-Language de-DE
X-BeenThere python-de@python.org
X-Mailman-Version 2.1.29
Precedence list
List-Id Die Deutsche Python Mailingliste <python-de.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-de>, <mailto:python-de-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-de/>
List-Post <mailto:python-de@python.org>
List-Help <mailto:python-de-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-de>, <mailto:python-de-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <54aef4d4-d183-2974-4374-8a6fc07aa9ad@thomas-guettler.de>
Xref csiph.com de.comp.lang.python:5296

Show key headers only | View raw


Hallo,

ich habe mal eine Idee veröffentlicht, die mir schon lange
vorschwebt:

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

Feedback is willkommen.


------------------------------


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).
Misc

     The name2type mapping is just a fall-back. First the IDE does the usual type detection and if no type could be 
found, then name2type mapping gets used. Except explicitly switched off. But this switch is not part of the spec.




-- 
Thomas Guettler http://www.thomas-guettler.de/
I am looking for feedback: https://github.com/guettli/programming-guidelines

Back to de.comp.lang.python | Previous | Next | Find similar


Thread

[Python-de] name2type mapping Thomas Güttler <guettliml@thomas-guettler.de> - 2018-10-26 09:53 +0200

csiph-web