79751669

Date: 2025-08-31 09:56:21
Score: 3
Natty:
Report link

After some testing, this is indeed a Pylance bug.

def foo[A: (int, str)](x: A, y: A) -> A:
    if isinstance(x, str):
        reveal_type(x)
        reveal_type(y) 
        # Type of "y" is "A@foo" (Pylance)
        # Revealed type is "builtins.str" (Mypy)
    return x + y

Thanks @dROOOze.

Reasons:
  • Blacklisted phrase (0.5): Thanks
  • Low length (0.5):
  • Has code block (-0.5):
  • User mentioned (1): @dROOOze
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: 小金貓