-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy path3.13.py
More file actions
executable file
·37 lines (22 loc) · 810 Bytes
/
3.13.py
File metadata and controls
executable file
·37 lines (22 loc) · 810 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python3.13
# https://docs.python.org/3.13/whatsnew/3.13.html
from passed import passed
import typing as _typing
from warnings import deprecated, catch_warnings, simplefilter
from typing import TypeIs, ReadOnly, TypedDict
# PEP 742: typing.TypeIs for intuitive type narrowing
def is_str(value: object) -> TypeIs[str]:
return isinstance(value, str)
unknown: object = "hello"
if is_str(unknown):
assert unknown.upper() == "HELLO"
# PEP 705: typing.ReadOnly for immutable fields in TypedDict
class Config(TypedDict):
env: ReadOnly[str]
cfg: Config = {"env": "production"}
assert cfg["env"] == "production"
# PEP 702: deprecation decorator – pick from typing or warnings; fallback to no-op
@deprecated("use 'new_api' instead")
def old_api() -> int:
return 1
passed()