python-keycloak icon indicating copy to clipboard operation
python-keycloak copied to clipboard

Wrong typehints for raw post/get methods of KeycloakOpenIDConnection

Open Ujifman opened this issue 7 months ago • 1 comments

After update I catched strange mypy errors

src\keycloak_migrator\keycloak_facade.py:89: error: Argument 1 to "raw_post" of "KeycloakOpenIDConnection" has incompatible type "str"; expected "list[Any]"  [arg-type]
src\keycloak_migrator\keycloak_facade.py:90: error: Argument "data" to "raw_post" of "KeycloakOpenIDConnection" has incompatible type "str"; expected "dict[Any, Any]"  [arg-type]       
src\keycloak_migrator\keycloak_facade.py:94: error: Argument 2 to "raise_error_from_response" has incompatible type "type[KeycloakPostError]"; expected "dict[Any, Any] | Exception"  [arg-type]
src\keycloak_migrator\keycloak_facade.py:306: error: Argument "audience" to "token" of "KeycloakOpenID" has incompatible type "str"; expected "dict[Any, Any]"  [arg-type]
Found 4 errors in 1 file (checked 37 source files)
Image

I think sombody made wrong typehints. args is tuple but not a list. But its really bad idea of typyhinting args/kwargs, as they are abstractions for passing params through, so there should not be typehints. What are the purpose of this typehinting?

Ujifman avatar Sep 06 '25 10:09 Ujifman

I've also seen plenty of these as Pyright warnings while developing. Sounds like you may be right about not typing kwargs. I see these type of warnings everywhere in the repo

gregriff avatar Sep 08 '25 22:09 gregriff