Skip to content

(🐞) New union syntax inconsistent with old union syntax, now it contains Any #12224

Closed
@KotlinIsland

Description

@KotlinIsland
from typing import Union
class A:
    def __init__(self, a): ...
    
Test1 = str | A  # error
Test2 = Union[str, A]

main.py:5: error: Expression type contains "Any" (has type "Type[A]")
But no error on the last line

https://mypy-play.net/?mypy=latest&python=3.10&flags=disallow-any-expr&gist=dd6dcaf336fb58d4afc3310200259630

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions