You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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.
I started working on that, but other projects have preempted that
effort. My current work is at univention/typeshed@8fc5f79,
but it not much more then generating the stubs using stubgen.
If someone wants to join that effort that is much appreciated.
This was proposed to the Mailing List. @tiran proposed to start the work only after the Python 2 legacy code is removed:
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.
The text was updated successfully, but these errors were encountered:
I would prefer not using .pyi. Inline type hints are much more useful, especially for documentation.
Unfortunately, stubgen doesn't seem too successful: neither annotating things with Any, not specifying None return values, nor determinig that constants are str or int, is very useful.
IMO, type hints are useful for documentation purposes.
I would love to use Sphinx's autofunction to generate function signatures in the reference docs; maybe that can be done along with the type annotations?
I would prefer not using .pyi. Inline type hints are much more useful, especially for documentation.
See my quote from @tiran - type hints will be added directly into the Python code .py files after the old Python 2 code has been purged.
For now I'm using the .pyi files as my project is still Python 2.
Unfortunately, stubgen doesn't seem too successful: neither annotating things with Any, not specifying None return values, nor determinig that constants are str or int, is very useful.
Yes, it's a lot of work as stubgen only provides a very basic template. There are other tools which can generate better stubs by using runtime information - it's on my todo list to try them out.
IMO, type hints are useful for documentation purposes.
I would love to use Sphinx's autofunction to generate function signatures in the reference docs; maybe that can be done along with the type annotations?
Yes, I'm already using sphinx-autodoc-typehints, which re-uses the Python type annotation for Sphinx documentation, too.
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 likehttp://mypy-lang.org/ or https://github.com/google/pytype/.
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
since Python 3.5 or in a Python-2 backward compatible way as
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.
I started working on that, but other projects have preempted that
effort. My current work is at
univention/typeshed@8fc5f79,
but it not much more then generating the stubs using
stubgen
.If someone wants to join that effort that is much appreciated.
This was proposed to the Mailing List.
@tiran proposed to start the work only after the Python 2 legacy code is removed:
The text was updated successfully, but these errors were encountered: