Skip to content

Commit 8e3144d

Browse files
authored
Merge pull request #48 from TomJGooding/build-update-supported-python-versions
build!: update supported Python versions
2 parents 6485ab6 + f7ea63b commit 8e3144d

File tree

9 files changed

+964
-883
lines changed

9 files changed

+964
-883
lines changed

.github/workflows/pythonpackage.yml

Lines changed: 9 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -19,46 +19,22 @@ jobs:
1919
strategy:
2020
matrix:
2121
os: [ubuntu-latest, macos-latest, windows-latest]
22-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
23-
# Python 3.9 is on macos-13 but not macos-latest (macos-14-arm64)
24-
# https://github.com/actions/setup-python/issues/696#issuecomment-1637587760
25-
exclude:
26-
- { python-version: "3.8", os: "macos-latest" }
27-
- { python-version: "3.9", os: "macos-latest" }
28-
- { python-version: "3.11", os: "macos-latest" }
29-
include:
30-
- { python-version: "3.8", os: "macos-13" }
31-
- { python-version: "3.9", os: "macos-13" }
32-
- { python-version: "3.11", os: "macos-13" }
22+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
3323
defaults:
3424
run:
3525
shell: bash
3626
steps:
37-
- uses: actions/[email protected]
38-
- name: Install and configure Poetry # This could be cached, too...
39-
uses: snok/[email protected]
40-
with:
41-
version: 1.4.2
42-
virtualenvs-in-project: true
27+
- uses: actions/[email protected]
28+
- name: Install Poetry
29+
run: pipx install poetry==1.7.1
4330
- name: Set up Python ${{ matrix.python-version }}
44-
uses: actions/setup-python@v5.2.0
31+
uses: actions/setup-python@v5
4532
with:
4633
python-version: ${{ matrix.python-version }}
47-
48-
- name: Load cached venv
49-
id: cached-poetry-dependencies
50-
uses: actions/cache@v3
51-
with:
52-
path: .venv
53-
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
34+
cache: "poetry"
5435
- name: Install dependencies
55-
run: poetry install
56-
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
36+
run: poetry install --no-interaction
5737
- name: Run mypy
58-
run: |
59-
source $VENV
60-
mypy .
38+
run: poetry run mypy .
6139
- name: Test with pytest
62-
run: |
63-
source $VENV
64-
pytest tests -v
40+
run: poetry run pytest tests -v

.pre-commit-config.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,3 @@ repos:
33
rev: 24.1.1
44
hooks:
55
- id: black
6-
language_version: python3.8
7-

poetry.lock

Lines changed: 929 additions & 839 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,18 @@ classifiers = [
1717
"Operating System :: Microsoft :: Windows :: Windows 11",
1818
"Operating System :: MacOS",
1919
"Operating System :: POSIX :: Linux",
20-
"Programming Language :: Python :: 3.8",
2120
"Programming Language :: Python :: 3.9",
2221
"Programming Language :: Python :: 3.10",
2322
"Programming Language :: Python :: 3.11",
23+
"Programming Language :: Python :: 3.12",
24+
"Programming Language :: Python :: 3.13",
25+
"Programming Language :: Python :: 3.14",
2426
"Typing :: Typed",
2527
]
2628
include = ["src/textual_dev/py.typed", { path = "tests", format = "sdist" }]
2729

2830
[tool.poetry.dependencies]
29-
python = "^3.8.1"
31+
python = "^3.9"
3032
textual = ">=0.86.2"
3133
textual_serve = ">=1.0.3"
3234
aiohttp = ">=3.8.1"

src/textual_dev/client.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
from textual.constants import DEVTOOLS_PORT
1919

2020
READY_TIMEOUT = 0.5
21-
WEBSOCKET_CONNECT_TIMEOUT = 3
2221
LOG_QUEUE_MAXSIZE = 512
2322

2423

@@ -116,8 +115,7 @@ async def connect(self) -> None:
116115
self.log_queue = Queue(maxsize=LOG_QUEUE_MAXSIZE)
117116
try:
118117
self.websocket = await self.session.ws_connect(
119-
f"{self.url}/textual-devtools-websocket",
120-
timeout=WEBSOCKET_CONNECT_TIMEOUT,
118+
f"{self.url}/textual-devtools-websocket"
121119
)
122120
except (ClientConnectorError, ClientResponseError):
123121
raise DevtoolsConnectionError()

src/textual_dev/server.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,17 @@ def _run_devtools(
4646
def noop_print(_: str) -> None:
4747
pass
4848

49+
try:
50+
loop = asyncio.get_event_loop()
51+
except RuntimeError:
52+
loop = asyncio.new_event_loop()
53+
4954
try:
5055
run_app(
5156
app,
5257
port=DEVTOOLS_PORT if port is None else port,
5358
print=noop_print,
54-
loop=asyncio.get_event_loop(),
59+
loop=loop,
5560
)
5661
except OSError:
5762
from rich import print

tests/devtools/conftest.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from typing import AsyncGenerator
12
import pytest
23

34
from textual_dev.client import DevtoolsClient
@@ -6,7 +7,9 @@
67

78

89
@pytest.fixture
9-
async def server(aiohttp_server, unused_tcp_port):
10+
async def server(
11+
aiohttp_server, unused_tcp_port
12+
) -> AsyncGenerator[DevtoolsService, None]:
1013
app = _make_devtools_aiohttp_app(
1114
size_change_poll_delay_secs=0.001,
1215
)

tests/devtools/test_devtools.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
from rich.align import Align
77
from rich.console import Console
88
from rich.segment import Segment
9+
from rich.table import Table
10+
from rich.text import Text
11+
from rich.rule import Rule
912

1013
from textual_dev.renderables import DevConsoleLog, DevConsoleNotice
1114

@@ -32,7 +35,7 @@ def console():
3235

3336

3437
@time_machine.travel(TIMESTAMP)
35-
def test_log_message_render(console):
38+
def test_log_message_render(console) -> None:
3639
message = DevConsoleLog(
3740
[Segment("content")],
3841
path="abc/hello.py",
@@ -43,19 +46,24 @@ def test_log_message_render(console):
4346
severity=0,
4447
)
4548
table = next(iter(message.__rich_console__(console, console.options)))
49+
assert isinstance(table, Table)
4650

4751
assert len(table.rows) == 1
4852

4953
columns = list(table.columns)
5054
left_cells = list(columns[0].cells)
5155
left = left_cells[0]
5256
right_cells = list(columns[1].cells)
57+
assert isinstance(right_cells[0], Align)
5358
right: Align = right_cells[0]
5459

5560
# Since we can't guarantee the timezone the tests will run in...
5661
local_time = datetime.fromtimestamp(TIMESTAMP)
5762
string_timestamp = local_time.time()
5863

64+
assert isinstance(left, Text)
65+
assert isinstance(right.renderable, Text)
66+
5967
assert left.plain == f"[{string_timestamp}] UNDEFINED"
6068
assert right.align == "right"
6169
assert "hello.py:123" in right.renderable
@@ -64,6 +72,7 @@ def test_log_message_render(console):
6472
def test_internal_message_render(console):
6573
message = DevConsoleNotice("hello")
6674
rule = next(iter(message.__rich_console__(console, console.options)))
75+
assert isinstance(rule, Rule)
6776
assert rule.title == "hello"
6877
assert rule.characters == "─"
6978

tests/devtools/test_devtools_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ async def test_devtools_log_spillover(devtools):
8585
}
8686

8787

88-
async def test_devtools_client_update_console_dimensions(devtools, server):
88+
async def test_devtools_client_update_console_dimensions(devtools, server) -> None:
8989
"""Sending new server info through websocket from server to client should (eventually)
9090
result in the dimensions of the devtools client console being updated to match.
9191
"""

0 commit comments

Comments
 (0)