Skip to content

Seemingly correct type narrowing, but still incompatible type #13744

Description

@hwong557

Bug Report

Mypy seems to type narrow correctly, but still throws an error when trying to add to a set.

To Reproduce

Gist URL: https://gist.github.com/c10befca044d78713b96a9706ac355b2
Playground URL: https://mypy-play.net/?mypy=master&python=3.10&gist=c10befca044d78713b96a9706ac355b2

Expected Behavior

No error.

Actual Behavior

main.py:15: error: Argument 1 to "add" of "set" has incompatible type "Data"; expected "Data"
Found 1 error in 1 file (checked 1 source file)

Your Environment

  • Mypy version used: mypy 0.990+dev.780534b13722b7b0422178c049a1cbbf4ea4255b (compiled: no)
  • Mypy command-line flags: none
  • Mypy configuration options from mypy.ini (and other config files): none
  • Python version used: 3.10.7

Activity

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

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions