pythongssapi / python-gssapi

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

Mypy error with creds type #313

Closed slmg closed 1 year ago

slmg commented 1 year ago

What went wrong?

Argument "creds" to "SecurityContext" has incompatible type "Creds"; expected "Optional[Credentials]"  [arg-type]

How do we reproduce?

import gssapi

server_creds = gssapi.Credentials.acquire().creds
server_context = gssapi.SecurityContext(creds=server_creds)

Component versions (python-gssapi, Kerberos, OS / distro, etc.)

Python 3.10.10 on Bullseye, gssapi 1.8.2 (pip-installed), mypy 1.1.1

jborean93 commented 1 year ago

Thanks for the bug report, I believe https://github.com/pythongssapi/python-gssapi/pull/314 fixes this problem for you.

I actually think this type annotation is there on purpose. The SecurityContext calls creds.usage which is a special property on gssapi.Credentials. Supporting the raw creds object here would require more work to support such a scenario.

jborean93 commented 1 year ago

Closing as per the above, the type is correct. It would be a new feature to accept the raw credential object and have it work here.