Skip to content

Commit 272d702

Browse files
authored
Merge branch 'master' into fastapi
2 parents 21ca43c + 0380626 commit 272d702

File tree

7 files changed

+85
-0
lines changed

7 files changed

+85
-0
lines changed

python-repl-314/.pythonstartup

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
try:
2+
from dataclasses import replace
3+
4+
from _colorize import ANSIColors, default_theme, set_theme
5+
except Exception:
6+
# Running on an older Python or environment without _colorize
7+
pass
8+
else:
9+
theme = default_theme.copy_with(
10+
syntax=replace(
11+
default_theme.syntax,
12+
keyword=ANSIColors.BOLD_YELLOW,
13+
string=ANSIColors.INTENSE_BLUE,
14+
number=ANSIColors.RED,
15+
comment=ANSIColors.GREY,
16+
),
17+
)
18+
set_theme(theme)

python-repl-314/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Python 3.14 Preview: REPL Autocompletion and Highlighting
2+
3+
This folder provides the code examples for the Real Python tutorial [Python 3.14 Preview: REPL Autocompletion and Highlighting](https://realpython.com/python-repl-autocompletion-highlighting/).
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import pathlib
2+
3+
BASE_DIR = pathlib.Path(".")
4+
number = 42
5+
fruits = ["apple", "grape", "orange"]
6+
7+
8+
def func(value):
9+
"""A sample docstring."""
10+
return f"The input value is: {value}"
11+
12+
13+
def main():
14+
# A sample comment
15+
func(number)
16+
for fruit in fruits:
17+
print(fruit)
18+
19+
20+
if __name__ == "__main__":
21+
main()

python-ty/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Astral's ty: A New Blazing-Fast Type Checker for Python
2+
3+
This folder contains sample code for the Real Python tutorial [Astral's ty: A New Blazing-Fast Type Checker for Python](https://realpython.com/python-ty/).

python-ty/adder.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# fmt:off
2+
3+
import warnings
4+
5+
type Number = int | float
6+
7+
8+
def new_adder(x: Number, y: Number) -> Number:
9+
return x + y
10+
11+
12+
@warnings.deprecated("Use the new_adder() instead")
13+
def legacy_adder(x, y):
14+
return x + y
15+
16+
17+
if __name__ == "__main__":
18+
legacy_adder( # ty: ignore
19+
42,
20+
555
21+
)
22+
23+
legacy_adder(
24+
42,
25+
555
26+
) # ty: ignore
27+
28+
new_adder(a=42, b=555) # ty: ignore[unknown-argument, missing-argument]

python-ty/cross_platform.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from sys import platform
2+
from typing import reveal_type
3+
4+
if platform == "win32":
5+
x = "Windows"
6+
else:
7+
x = "macOS or Linux"
8+
9+
reveal_type(x)

python-ty/python_version.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from typing import Literal
2+
3+
type Size = Literal["S", "M", "L", "XL"]

0 commit comments

Comments
 (0)