Skip to content

Commit ea6b625

Browse files
committed
[python-ldap] Integrate typing into the build/CI system
1 parent 84a1c18 commit ea6b625

File tree

5 files changed

+29
-7
lines changed

5 files changed

+29
-7
lines changed

Lib/ldap/py.typed

Whitespace-only changes.

MANIFEST.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
include MANIFEST.in Makefile CHANGES INSTALL LICENCE README TODO
22
include tox.ini .coveragerc
33
include Modules/*.c Modules/*.h
4+
include Lib/ldap/py.typed
5+
include Lib/_ldap.pyi
46
recursive-include Build *.cfg*
57
recursive-include Lib *.py
68
recursive-include Demo *.py

setup.cfg

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ defines = HAVE_SASL HAVE_TLS
2020

2121
extra_compile_args =
2222
extra_objects =
23+
extra_files = .:Lib/_ldap.pyi
2324

2425
# Uncomment this if your libldap is not thread-safe and you need libldap_r
2526
# instead
@@ -49,3 +50,14 @@ python_files = t_*.py
4950
filterwarnings =
5051
error
5152
ignore::ldap.LDAPBytesWarning
53+
54+
# mypy, https://mypy.readthedocs.io/en/latest/
55+
[mypy]
56+
strict = True
57+
files = Lib/
58+
59+
[mypy-pyasn1.*]
60+
ignore_missing_imports = True
61+
62+
[mypy-pyasn1_modules.*]
63+
ignore_missing_imports = True

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ class OpenLDAP2:
139139
py_modules = [
140140
'ldapurl',
141141
'ldif',
142-
143142
],
144143
packages = [
145144
'ldap',
@@ -150,11 +149,13 @@ class OpenLDAP2:
150149
'slapdtest.certs',
151150
],
152151
package_dir = {'': 'Lib',},
152+
package_data = {'ldap': ['py.typed'],},
153153
data_files = LDAP_CLASS.extra_files,
154154
include_package_data=True,
155155
install_requires=[
156156
'pyasn1 >= 0.3.7',
157157
'pyasn1_modules >= 0.1.5',
158+
'typing_extensions >= 0.4.1',
158159
],
159160
zip_safe=False,
160161
python_requires='>=3.9',

tox.ini

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55

66
[tox]
77
# Note: when updating Python versions, also change setup.py and .github/worlflows/*
8-
envlist = py{39,310,311,312},py3-nosasltls,doc,py3-trace,pypy3.9
8+
envlist = py{39,310,311,312},py3-nosasltls,doc,mypy,py3-trace,pypy3.9
99
minver = 1.8
1010

1111
[gh-actions]
1212
python =
13-
3.9: py39, py3-trace, doc, py3-nosasltls
14-
3.10: py310
15-
3.11: py311
16-
3.12: py312
17-
3.13: py313
13+
3.9: py39, py3-trace, doc, py3-nosasltls, mypy
14+
3.10: py310, mypy
15+
3.11: py311, mypy
16+
3.12: py312, mypy
17+
3.13: py313, mypy
1818
pypy3.9: pypy3.9
1919
pypy3.10: pypy3.10
2020

@@ -41,6 +41,7 @@ deps =
4141
{[testenv]deps}
4242
pyasn1
4343
pyasn1_modules
44+
typing_extensions
4445
passenv = {[testenv]passenv}
4546
setenv =
4647
CI_DISABLED=LDAPI:SASL:TLS
@@ -90,6 +91,12 @@ basepython = pypy3
9091
deps = pytest
9192
commands = {envpython} -m pytest {posargs}
9293

94+
[testenv:mypy]
95+
basepython = python3
96+
deps = mypy
97+
commands =
98+
{envpython} -m mypy --config-file {toxinidir}/setup.cfg {posargs}
99+
93100
[testenv:doc]
94101
basepython = python3
95102
deps =

0 commit comments

Comments
 (0)