mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 12:55:05 +00:00

<!-- Thank you for contributing to Ruff! To help us out with reviewing, please consider the following: - Does this pull request include a summary of the change? (See below.) - Does this pull request include a descriptive title? - Does this pull request include references to any relevant issues? --> ## Summary fixes #15048 We want to handle more types from Type::KnownInstance ## Test Plan Add tests for each type added explicitly in the match --------- Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
599 B
599 B
Protocols
We do not support protocols yet, but to avoid false positives, we partially support some known protocols.
typing.SupportsIndex
from typing import SupportsIndex, Literal
def _(some_int: int, some_literal_int: Literal[1], some_indexable: SupportsIndex):
a: SupportsIndex = some_int
b: SupportsIndex = some_literal_int
c: SupportsIndex = some_indexable
Invalid
from typing import Protocol
# error: [invalid-type-form] "`typing.Protocol` is not allowed in type expressions"
def f(x: Protocol) -> None:
reveal_type(x) # revealed: Unknown