Skip to content

Typing: Intersphinx: mypy type errors in inventory loading #12864

Closed

Description

@jayaddison

Describe the bug

Typeshed update python/typeshed#12616 adds a type-hint for the requests.Response.raw attribute, and mypy fails some Intersphinx loading code with that change in place, as encountered during a recent continuous integration job.

How to Reproduce

  • Clone and checkout a recent commit from sphinx.git (for example, 0438178).
  • Install mypy==1.11.1.
  • Install types-requests==2.32.0.20240905.
  • Run mypy sphinx/ext/intersphinx/_load.py.
  • Observe the errors below (they should be identical / very similar to those reported by mypy_primer):
$ mypy sphinx/ext/intersphinx/_load.py 
sphinx/ext/intersphinx/_load.py: note: In function "_read_from_url":
sphinx/ext/intersphinx/_load.py:383:5: error: Cannot assign to a method  [method-assign]
sphinx/ext/intersphinx/_load.py:383:18: error: "Callable[[int | None, bool | None, bool], bytes] | Any" not callable  [misc]
sphinx/ext/intersphinx/_load.py:384:12: error: Incompatible return value type (got "HTTPResponse | Any", expected "IO[Any]")  [return-value]
Found 3 errors in 1 file (checked 1 source file)

Environment Information

Platform:              linux; (Linux-6.10.6-rt-amd64-x86_64-with-glibc2.40)
Python version:        3.12.5 (main, Aug 22 2024, 13:11:09) [GCC 14.2.0])
Python implementation: CPython
Sphinx version:        8.1.0+/04381789d
Docutils version:      0.21.2
Jinja2 version:        3.1.4
Pygments version:      2.18.0

Sphinx extensions

N/A

Additional context

N/A

Activity

  1. added this to the 8.1.0 milestone on Oct 6, 2024
  2. locked as resolved and limited conversation to collaborators on Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions