[python-ldap] PEP 484 -- Type Hints for python-ldap?

Philipp Hahn hahn at univention.de
Mon Jun 29 04:04:33 EDT 2020


Hello,

Am 18.06.20 um 16:19 schrieb Petr Viktorin:
> This is the last 3.x release of python-ldap to support CPython 2.7, 3.4
> and 3.5, which are past or near end-of-life. For information on
> supported CPython versions, see:
>
>      https://devguide.python.org/#status-of-python-branches
>      https://devguide.python.org/devcycle/#end-of-life-branches

Python supports type hints to improve static analysis:
<https://www.python.org/dev/peps/pep-0484/>
This helps to identify cases, were wrong types are passed into functions
et al by using type checkers like<http://mypy-lang.org/> or
<https://github.com/google/pytype/>.

Sadly "python-ldap" does not yet seem to contain those annotations nor
am I aware of any project doing that.
Those annotation can either we added directly in the library like

> def func(arg: str, val: int = 0) -> Tuple[int, str]

since Python 3.5 or in a Python-2 backward compatible way as

> def func(arg, val=0):  # type: (str, int) -> Tuple[int, str]

As an alternative the annotations can be put into so-called "stub files"
names "*.pyi", which are collected by
<https://github.com/python/typeshed>, but inline annotations are
preferred as they are easier to keep in sync.

Is someone working on that?
Would such an effort be appreciated?

I started working on that, but other projects have preempted that
effort. My current work is at
<https://github.com/univention/typeshed/commit/8fc5f796d4ef009e5cf8282575ae304994170b25>,
but it not much more then generating the stubs using `stubgen`.
If someone wants to join that effort that is much appreciated.

Philipp
-- 
Philipp Hahn
Open Source Software Engineer

Univention GmbH
be open.
Mary-Somerville-Str. 1
D-28359 Bremen

Tel.: +49-421-22232-57
Fax : +49-421-22232-99

hahn at univention.de
https://www.univention.de/

Geschäftsführer: Peter H. Ganten
HRB 20755 Amtsgericht Bremen
Steuer-Nr.: 71-597-02876


More information about the python-ldap mailing list