Skip to content

mypy duplicates reveal_type notes with partial types #18511

Closed
@A5rocks

Description

@A5rocks

Bug Report

There's two notes from a single reveal_type with a partial type in a loop.

To Reproduce

def main() -> None:
    x = None
    while True:
        reveal_type(x)
        x = ""

(the outer function is only necessary to make sure a transition to --local-partial-types doesn't render this test case useless)

Expected Behavior

main.py:4: note: Revealed type is "Union[builtins.str, None]"
Success: no issues found in 1 source file

Actual Behavior

main.py:4: note: Revealed type is "None"
main.py:4: note: Revealed type is "Union[builtins.str, None]"
Success: no issues found in 1 source file

Your Environment

I assume this was caused by #18180. Checked on mypy playground.

  • Mypy version used: master
  • Mypy command-line flags: none
  • Mypy configuration options from mypy.ini (and other config files): none
  • Python version used: 3.12

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-reveal-typereveal_type() and reveal_locals()

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions