Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b72364d

Browse files
dkgjborean93
authored andcommitted
Enable the use of mypy --no-explicit-reexport on downstream projects
When testing simple python code like this with mypy for type-safety: ``` import gssapi gsc:gssapi.SecurityContext gsc = gssapi.SecurityContext( usage='initiate', name=gssapi.Name('imap@localhost', gssapi.NameType.hostbased_service)) ``` I see these errors: ``` 0 $ mypy --no-implicit-reexport ./test.py test.py:3: error: Name "gssapi.SecurityContext" is not defined [name-defined] test.py:4: error: Module "gssapi" does not explicitly export attribute "SecurityContext" [attr-defined] test.py:4: error: Module "gssapi" does not explicitly export attribute "Name" [attr-defined] test.py:4: error: Module "gssapi" does not explicitly export attribute "NameType" [attr-defined] Found 4 errors in 1 file (checked 1 source file) 1 $ ``` The same thing happens when using `mypy --strict`. [a blogpost](https://til.codeinthehole.com/posts/how-to-handle-convenience-imports-with-mypy/) suggested that the `__all__` variable in `gssapi/__init__.py` might be the way to fix this. I can confirm that it does clear the error, but I'm not enough of a python module expert to know whether there might be some undesirable side effects as well to making this change. Please review! Tested on debian testing/unstable, with: - python3 3.11.6-1 - python3-gssapi 1.8.2-1+b2 - mypy 1.8.0-1 Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
1 parent e509231 commit b72364d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

‎gssapi/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,17 @@
3838
from gssapi.mechs import Mechanism # noqa
3939

4040
from gssapi._utils import set_encoding # noqa
41+
42+
__all__ = [
43+
'AddressType',
44+
'Credentials',
45+
'IntEnumFlagSet',
46+
'Mechanism',
47+
'MechType',
48+
'Name',
49+
'NameType',
50+
'OID',
51+
'RequirementFlag',
52+
'SecurityContext',
53+
'set_encoding',
54+
]

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /