Skip to content

False negatives with dict.__(r)or__ #10678

@adamtheturtle

Description

@adamtheturtle

I have code equivalent to the following:

from requests.structures import CaseInsensitiveDict

CaseInsensitiveDict() | dict()

mypy does not error.

My environment has:

  • mypy==1.5.1
  • types-requests==2.31.0.2
  • Python 3.11.5

At runtime I get:

TypeError: unsupported operand type(s) for |: 'CaseInsensitiveDict' and 'dict'

I would expect an [operator] error. For example, if I swap the CaseInsensitiveDict() for 1, I get:

error: Unsupported operand types for | ("int" and "dict[str, str]")  [operator]

I am happy to contribute, but I'm not sure what change is needed. I imagine a change is needed in https://github.com/python/typeshed/blob/main/stubs/requests/requests/structures.pyi.

Metadata

Metadata

Assignees

No one assigned

    Labels

    stubs: false negativeType checkers do not report an error, but should

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions