Skip to content

Commit

Permalink
[red-knot] Make attributes.md test future-proof (#14923)
Browse files Browse the repository at this point in the history
## Summary

Using `typing.LiteralString` breaks as soon as we understand
`sys.version_info` branches, as it's only available in 3.11 and later.

## Test Plan

Made sure it didn't fail on my #14759 branch anymore.
  • Loading branch information
sharkdp authored Dec 11, 2024
1 parent c361cf6 commit a7e5e42
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ def _(flag: bool):
## Objects of all types have a `__class__` method

```py
import typing
import typing_extensions

reveal_type(typing.__class__) # revealed: Literal[ModuleType]
reveal_type(typing_extensions.__class__) # revealed: Literal[ModuleType]

a = 42
reveal_type(a.__class__) # revealed: Literal[int]
Expand All @@ -138,7 +138,7 @@ reveal_type(d.__class__) # revealed: Literal[bool]
e = (42, 42)
reveal_type(e.__class__) # revealed: Literal[tuple]

def f(a: int, b: typing.LiteralString, c: int | str, d: type[str]):
def f(a: int, b: typing_extensions.LiteralString, c: int | str, d: type[str]):
reveal_type(a.__class__) # revealed: type[int]
reveal_type(b.__class__) # revealed: Literal[str]
reveal_type(c.__class__) # revealed: type[int] | type[str]
Expand Down

0 comments on commit a7e5e42

Please sign in to comment.