mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-03 07:04:37 +00:00
add test for typing_extensions.Self (#17995)
Using `typing_extensions.Self` already worked, but we were lacking a test for it.
This commit is contained in:
parent
882a1a702e
commit
fd1eb3d801
2 changed files with 18 additions and 2 deletions
|
@ -50,6 +50,23 @@ class Outer:
|
||||||
return self
|
return self
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## typing_extensions
|
||||||
|
|
||||||
|
```toml
|
||||||
|
[environment]
|
||||||
|
python-version = "3.10"
|
||||||
|
```
|
||||||
|
|
||||||
|
```py
|
||||||
|
from typing_extensions import Self
|
||||||
|
|
||||||
|
class C:
|
||||||
|
def method(self: Self) -> Self:
|
||||||
|
return self
|
||||||
|
|
||||||
|
reveal_type(C().method()) # revealed: C
|
||||||
|
```
|
||||||
|
|
||||||
## Class Methods
|
## Class Methods
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
|
|
|
@ -86,8 +86,7 @@ pub enum KnownInstanceType<'db> {
|
||||||
/// The symbol `typing.Callable`
|
/// The symbol `typing.Callable`
|
||||||
/// (which can also be found as `typing_extensions.Callable` or as `collections.abc.Callable`)
|
/// (which can also be found as `typing_extensions.Callable` or as `collections.abc.Callable`)
|
||||||
Callable,
|
Callable,
|
||||||
|
/// The symbol `typing.Self` (which can also be found as `typing_extensions.Self`)
|
||||||
/// The symbol `typing.Self`
|
|
||||||
TypingSelf,
|
TypingSelf,
|
||||||
|
|
||||||
// Various special forms, special aliases and type qualifiers that we don't yet understand
|
// Various special forms, special aliases and type qualifiers that we don't yet understand
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue