Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ jobs:
fail-fast: false
matrix:
include:
- python-version: "3.9"
platform: ubuntu-latest
toxenv: py39
- python-version: "3.10"
platform: ubuntu-latest
toxenv: py310
Expand All @@ -32,12 +29,15 @@ jobs:
- python-version: "3.13"
platform: ubuntu-latest
toxenv: py313
- python-version: "3.12"
- python-version: "3.14"
platform: ubuntu-latest
toxenv: py314
- python-version: "3.14"
platform: macos-latest
toxenv: py312
- python-version: "3.12"
toxenv: py314
- python-version: "3.14"
platform: windows-latest
toxenv: py312
toxenv: py314

steps:
- uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.12.7
rev: v0.14.10
hooks:
- id: ruff
args: [--fix]
- id: ruff-format
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
rev: v6.0.0
hooks:
- id: check-added-large-files
- id: check-ast
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ log_level = "DEBUG"
[tool.ruff]
exclude = ["asan_symbolize.py"]
fix = true
target-version = "py39"
target-version = "py310"

[tool.ruff.lint]
select = [
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ package_dir =
= src
packages =
ffpuppet
python_requires = >=3.9
python_requires = >=3.10
zip_safe = False

[options.entry_points]
Expand Down
12 changes: 4 additions & 8 deletions src/ffpuppet/bootstrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,12 @@
from select import select
from socket import SO_REUSEADDR, SOL_SOCKET, socket
from time import perf_counter, sleep
from typing import TYPE_CHECKING, Callable

# as of python 3.10 socket.timeout was made an alias of TimeoutError
# pylint: disable=ungrouped-imports,wrong-import-order
from socket import timeout as socket_timeout # isort: skip
from typing import TYPE_CHECKING

from .exceptions import BrowserTerminatedError, BrowserTimeoutError, LaunchError

if TYPE_CHECKING:
from collections.abc import Iterable
from collections.abc import Callable, Iterable

LOG = getLogger(__name__)

Expand Down Expand Up @@ -217,7 +213,7 @@ def wait(
try:
count_recv = len(conn.recv(self.BUF_SIZE))
total_recv += count_recv
except socket_timeout:
except TimeoutError:
# use -1 to indicate timeout
count_recv = -1
if count_recv == self.BUF_SIZE:
Expand Down Expand Up @@ -250,7 +246,7 @@ def wait(
LOG.debug("sending response (redirect: %s)", url)
try:
conn.sendall(resp.encode("ascii"))
except socket_timeout:
except TimeoutError:
resp_timeout = True
else:
resp_timeout = False
Expand Down
4 changes: 2 additions & 2 deletions src/ffpuppet/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
from abc import ABC, abstractmethod
from os import SEEK_SET, stat
from platform import system
from typing import IO, TYPE_CHECKING, Callable
from typing import IO, TYPE_CHECKING

from psutil import AccessDenied, NoSuchProcess, Process

if TYPE_CHECKING:
from collections.abc import Iterable
from collections.abc import Callable, Iterable
from re import Pattern

__author__ = "Tyson Smith"
Expand Down
4 changes: 2 additions & 2 deletions src/ffpuppet/process_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from os import getenv
from pathlib import Path
from time import perf_counter, sleep
from typing import TYPE_CHECKING, Callable, cast
from typing import TYPE_CHECKING, cast

from psutil import (
STATUS_ZOMBIE,
Expand All @@ -25,7 +25,7 @@
from .exceptions import TerminateError

if TYPE_CHECKING:
from collections.abc import Generator, Iterable
from collections.abc import Callable, Generator, Iterable
from subprocess import Popen

if sys.platform != "win32":
Expand Down
16 changes: 6 additions & 10 deletions src/ffpuppet/test_bootstrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
"""ffpuppet bootstrapper tests"""
# pylint: disable=protected-access

# as of python 3.10 socket.timeout was made an alias of TimeoutError
# pylint: disable=ungrouped-imports
from socket import timeout as socket_timeout # isort: skip

from itertools import repeat
from socket import socket
from threading import Thread
Expand Down Expand Up @@ -61,7 +57,7 @@ def test_bootstrapper_03(mocker):
"""test Bootstrapper.wait() failure waiting for request"""
fake_sock = mocker.MagicMock(spec_set=socket)
fake_conn = mocker.Mock(spec_set=socket)
fake_conn.recv.side_effect = socket_timeout
fake_conn.recv.side_effect = TimeoutError
fake_sock.accept.return_value = (fake_conn, None)
mocker.patch("ffpuppet.bootstrapper.select", return_value=([fake_sock], None, None))
with Bootstrapper(fake_sock) as bts:
Expand All @@ -85,7 +81,7 @@ def test_bootstrapper_04(mocker):
fake_sock = mocker.MagicMock(spec_set=socket)
fake_conn = mocker.Mock(spec_set=socket)
fake_conn.recv.return_value = "A"
fake_conn.sendall.side_effect = socket_timeout
fake_conn.sendall.side_effect = TimeoutError
fake_sock.accept.return_value = (fake_conn, None)
mocker.patch("ffpuppet.bootstrapper.select", return_value=([fake_sock], None, None))
with Bootstrapper(fake_sock) as bts:
Expand Down Expand Up @@ -127,13 +123,13 @@ def test_bootstrapper_05(mocker):
# with a redirect url
("http://127.0.0.1:9999/test.html", ("foo",), 1),
# request size matches buffer size
(None, ("A" * Bootstrapper.BUF_SIZE, socket_timeout), 1),
(None, ("A" * Bootstrapper.BUF_SIZE, TimeoutError), 1),
# large request
(None, ("A" * Bootstrapper.BUF_SIZE, "foo"), 1),
# slow startup
(None, (socket_timeout, socket_timeout, "foo"), 1),
(None, (TimeoutError, TimeoutError, "foo"), 1),
# slow failed startup with retry
(None, (socket_timeout, "", "foo"), 2),
(None, (TimeoutError, "", "foo"), 2),
],
)
def test_bootstrapper_06(mocker, redirect, recv, closed):
Expand Down Expand Up @@ -162,7 +158,7 @@ def _fake_browser(port, payload_size=5120):
try:
conn.connect(("127.0.0.1", port))
break
except socket_timeout:
except TimeoutError:
if not attempt:
raise
# send request and receive response
Expand Down
2 changes: 1 addition & 1 deletion src/ffpuppet/test_ffpuppet.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ def test_ffpuppet_16(tmp_path):
with (
FFPuppet() as ffp,
HTTPTestServer() as srv,
raises(LaunchError, match="'.+?' is invalid"),
raises(LaunchError, match=r"'.+?' is invalid"),
):
ffp.launch(TESTFF_BIN, location=srv.get_addr(), prefs_js=prefs)

Expand Down
6 changes: 3 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py{39,310,311,312,313},lint
envlist = py{310,311,312,313,314},lint
skip_missing_interpreters = true
tox_pip_extensions_ext_venv_update = true

Expand Down Expand Up @@ -40,14 +40,14 @@ skip_install = true
commands =
mypy --install-types --non-interactive {posargs}
deps =
mypy==v1.17.1
mypy==v1.19.1
usedevelop = true

[testenv:pylint]
commands =
pylint -j 0 {posargs}
deps =
pylint==3.3.7
pylint==4.0.4
usedevelop = true

[testenv:pypi]
Expand Down