Skip to content

[simplejson] Replace Incomplete in JSONDecoder and fix scan_once return type - #16666

Open
huuan26 wants to merge 2 commits into
python:mainfrom
huuan26:fix/simplejson-decoder-types
Open

huuan26 wants to merge 2 commits into
python:mainfrom
huuan26:fix/simplejson-decoder-types

Conversation

@huuan26

@huuan26 huuan26 commented Oct 31, 2026 •

Copy link
Copy Markdown

Summary

This PR improves type annotations in simplejson.JSONDecoder:

  1. Fix scan_once return type: previously typed as Callable[[str, int], tuple[bool, int]]. At runtime, scan_once parses any JSON value (string, number, array, object, bool, null) and returns tuple[Any, int] representing (parsed_value, end_idx).
  2. Replace Incomplete with concrete types:
    • parse_string: returns tuple[str, int].
    • parse_object and parse_array: return tuple[Any, int].
  3. Remove unused from _typeshed import Incomplete.
  4. Add assert_type tests covering JSONDecoder methods in stubs/simplejson/@tests/test_cases/check_simplejson.py.

Verification

  • flake8 stubs/simplejson: passed (0 errors)
  • python tests/regr_test.py simplejson: passed with mypy
  • python tests/stubtest_third_party.py simplejson: passed (success against installed simplejson)
  • python tests/check_typeshed_structure.py: passed

@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant