Skip to content

False positive with assignment expression shadowing a builtin #15904

Open
@eltoder

Description

To Reproduce

https://mypy-play.net/?mypy=latest&python=3.11&gist=a7fd112a423a2e565e5f2cd3e3607e58

def foo(x: int) -> int:
    res = vars + 1 if (vars := x) else 0
    return res

Expected Behavior

This should type check without errors. It does if I rename vars to anything that is not a name of a built-in.

Actual Behavior

main.py:2: error: Unsupported operand types for + (overloaded function and "int")  [operator]

Your Environment

  • Mypy version used: 1.5.1
  • Mypy command-line flags: no
  • Mypy configuration options from mypy.ini (and other config files): no
  • Python version used: 3.11

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-pep-572PEP 572 (walrus operator)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions