pyjson5 icon indicating copy to clipboard operation
pyjson5 copied to clipboard

typing error in dumps

Open ggilley opened this issue 5 months ago • 2 comments

In dumps, the **kw at the end causes an unknown type error:

Type of "dumps" is partially unknown
  Type of "dumps" is "(obj: Any, *, skipkeys: bool = False, ensure_ascii: bool = True, check_circular: bool = True, allow_nan: bool = True, cls: type[JSON5Encoder] | None = None, indent: int | str | None = None, separators: Tuple[str, str] | None = None, default: ((Any) -> Any) | None = None, sort_keys: bool = False, quote_keys: bool = False, trailing_commas: bool = True, allow_duplicate_keys: bool = True, quote_style: QuoteStyle = QuoteStyle.ALWAYS_DOUBLE, **kw: Unknown) -> str"Pylance[reportUnknownMemberType](https://github.com/microsoft/pylance-release/blob/main/docs/diagnostics/reportUnknownMemberType.md)

adding type ": Any" to the **kw arg fixes it.

def dumps(
    obj: Any,
    *,
    skipkeys: bool = False,
    ensure_ascii: bool = True,
    check_circular: bool = True,
    allow_nan: bool = True,
    cls: Optional[Type['JSON5Encoder']] = None,
    indent: Optional[Union[int, str]] = None,
    separators: Optional[Tuple[str, str]] = None,
    default: Optional[Callable[[Any], Any]] = None,
    sort_keys: bool = False,
    quote_keys: bool = False,
    trailing_commas: bool = True,
    allow_duplicate_keys: bool = True,
    quote_style: QuoteStyle = QuoteStyle.ALWAYS_DOUBLE,
    **kw: Any,
):

ggilley avatar Jul 12 '25 22:07 ggilley

Never mind. it's a "strict" pyright check. I'll turn it off.

ggilley avatar Jul 12 '25 23:07 ggilley

Looks like it's probably the right fix anyway, though.

dpranke avatar Jul 17 '25 16:07 dpranke