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

Christian Heimes christian at python.org
Mon Jun 29 05:26:31 EDT 2020


On 29/06/2020 10.04, Philipp Hahn wrote:
> 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.

Hi,

we are planning to drop support for Python 3.5 and earlier in the next
version of python-ldap. This would make it simpler to add signatures for
type hints directly to the code base. Patches are welcome, but please
wait until we have finalized Python 2 cleanup in master.

Could you please open a bug on https://github.com/python-ldap/python-ldap ?

One personal note:
I don't like how you phrased 'Sadly "python-ldap" does not yet seem to
contain those annotations'. It feels like you are putting emotional
pressure on us and shaming us for not providing more free labor. It was
probably not your intention, but I still like to point out that the
prase is problematic.

Christian



More information about the python-ldap mailing list