pythongssapi / python-gssapi

A Python interface to RFC 2743/2744 (plus common extensions)
ISC License
103 stars 45 forks source link

Enable the use of `mypy --no-explicit-reexport` on downstream projects #338

Closed dkg closed 7 months ago

dkg commented 7 months ago

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 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:

jborean93 commented 7 months ago

I'll have to look into why the build is failing, maybe cibuildwheel pushed an update which broke something.

dkg commented 7 months ago

thanks for the prompt review, @jborean93 ! let me know if you need anything else.

jborean93 commented 7 months ago

Looks like a temporary problem, rerunning a few hours later and it now works.