mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 18:28:24 +00:00
wip
This commit is contained in:
parent
7264c7dff9
commit
66932b5087
1 changed files with 11 additions and 0 deletions
|
@ -63,4 +63,15 @@ def i(x: int | LiteralString):
|
|||
reveal_type(x) # revealed: (int & <Protocol with members 'capitalize'>) | LiteralString
|
||||
else:
|
||||
reveal_type(x) # revealed: int & ~<Protocol with members 'capitalize'>
|
||||
|
||||
def chained_narrowing(x: object):
|
||||
if hasattr(x, "foo") and hasattr(x, "bar"):
|
||||
reveal_type(x) # revealed: <Protocol with members 'foo'> & <Protocol with members 'bar'>
|
||||
reveal_type(x.foo) # revealed: object
|
||||
reveal_type(x.bar) # revealed: object
|
||||
|
||||
def stringify(x: object):
|
||||
if hasattr(x, "__module__") and hasattr(x, "__qualname__"):
|
||||
reveal_type(x.__module__) # revealed: object
|
||||
reveal_type(x.__qualname__) # revealed: object
|
||||
```
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue