Skip to content

Incorrect evaluation of | between classes and non-classes #1478

@AlexWaygood

Description

@AlexWaygood

Summary

The special cases added in astral-sh/ruff#21195 are a little too broad. Here's our behaviour on main:

class Foo:
    def __ror__(self, other) -> str:
        return "foo"

reveal_type(int | Foo())  # `UnionType`, but should be `str`
reveal_type(int | 42)  # `UnionType` (and no diagnostic), but this fails at runtime

Version

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions