joserfc icon indicating copy to clipboard operation
joserfc copied to clipboard

mypy issues

Open aldbr opened this issue 8 months ago • 0 comments

Dear developers,

  1. mypy is complaining about the KeySetSerialization type:
error: Argument 1 to "import_key_set" of "KeySet" has incompatible type "dict[Any, Any]"; expected "KeySetSerialization"  [arg-type]

I should likely import it from https://github.com/authlib/joserfc/blob/main/src/joserfc/_keys.py but this looks like a private module and KeySetSerialization does not seem to be part of the exported members: https://github.com/authlib/joserfc/blob/7982683c1e6dc68554169c393412a2d0818e4d22/src/joserfc/_keys.py#L12-L20

Is that expected?

  1. mypy is also complaining about the get method in https://github.com/authlib/joserfc/blob/main/src/joserfc/rfc7517/models.py when we set the default value as []:
key_ops = key.get("key_ops", [])
error: Argument 2 to "get" of "BaseKey" has incompatible type "list[Never]"; expected "str | None"  [arg-type]

It's because the expected type of default does not include list (only str or None), is that expected? https://github.com/authlib/joserfc/blob/7982683c1e6dc68554169c393412a2d0818e4d22/src/joserfc/rfc7517/models.py#L115

I can open a PR to perform the changes I am describing here if required.

Thanks

aldbr avatar May 05 '25 16:05 aldbr