facebook / facebook/pyrefly

`type[Alias]` where `Alias = Generic[Bound]` not assignable from subclass

Open
#3,192 1 comment 0 reactions 0 assignees View on GitHub
typechecking
Dominant language
Rust
Stars
7k
Forks
516
PR merge metrics
No merged PRs in 30d

Description

### Describe the Bug

**Python**: 3.13
**Pyrefly**: 0.62.0

**Code**:
```python
from typing import TypeAlias

class kAnyNode: ...
class kNode_Connection(kAnyNode): ...
class BaseNode[TK: kAnyNode = kAnyNode]: ...

AnyNode = BaseNode[kAnyNode]
TalendNodeType: TypeAlias = type[AnyNode]

class tNode_MysqlConnection(BaseNode[kNode_Connection]): ...

d: dict[str, TalendNodeType] = {
"mysql": tNode_MysqlConnection,
}
```

**Error**: `dict[str, type[tNode_MysqlConnection]]` is not assignable to `dict[str, type[BaseNode]]`

**Expected**: no error — `tNode_MysqlConnection` extends `BaseNode[kNode_Connection]`
which is a subtype of `BaseNode[kAnyNode]` = `AnyNode`

### Sandbox Link

_No response_

### (Only applicable for extension issues) IDE Information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.