Replies: 1 comment 2 replies
-
From a type analysis perspective, there's nothing wrong with unions that contain mutual subtypes, so that in itself is not a bug. Unions are created in may ways during type evaluation. The examples you've listed above involve the most straightforward way involving a There are two questions that I think we need to answer here.
|
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Inspired by flake8-pyi's Y041 (redundant numeric unions), Y051 (redundant unions between Literal types and builtin supertypes), PyCQA/flake8-pyi#283 (comment) and typescript-eslint's
no-redundant-type-constituents
. Is it possible to check if a type union is redundant? I expect this could get really complex, especially with type alias and protocols. So maybe just checking if a type inherits from another to start with.A few examples:
int | float
,object | None
,ChildClass | ParentClass
,str | Sequence[str]
Unions with
Any
should probably be ignored as it's an escape hatch and can still be used to partially express an expected type.Beta Was this translation helpful? Give feedback.
All reactions