Skip to content

No narrowing on is not None when using NoneType in a type annotation #2499

@superbobry

Description

@superbobry

Describe the Bug

Reproducer:

from types import NoneType

N = NoneType

def test(x: int | N):
  assert x is not None
  reveal_type(x)  # => NoneType | int

This looks like N is not normalized to None in the type of x.

Sandbox Link

No response

(Only applicable for extension issues) IDE Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions