Skip to content

Commit

Permalink
build: Drop support for Python 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Nov 26, 2024
1 parent c7171bf commit 1ca3aac
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 19 deletions.
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ description = "Command-line tool and library to interact with an aria2c daemon p
authors = [{name = "Timothée Mazzucotelli", email = "[email protected]"}]
license = {text = "ISC"}
readme = "README.md"
requires-python = ">=3.8"
requires-python = ">=3.9"
keywords = ["aria2", "aria2c", "aria2-cli"]
dynamic = ["version"]
classifiers = [
Expand All @@ -17,7 +17,6 @@ classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand Down
8 changes: 6 additions & 2 deletions src/aria2p/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import threading
from base64 import b64encode
from pathlib import Path
from typing import Callable, Dict, Iterator, List, TextIO, Tuple, Union
from typing import TYPE_CHECKING, Callable, TextIO, Union

from loguru import logger

Expand All @@ -20,9 +20,13 @@
from aria2p.options import Options
from aria2p.stats import Stats

if TYPE_CHECKING:
from collections.abc import Iterator


OptionsType = Union[Options, dict]
OperationResult = Union[bool, ClientException]
InputFileContentsType = List[Tuple[List[str], Dict[str, str]]]
InputFileContentsType = list[tuple[list[str], dict[str, str]]]


class API:
Expand Down
6 changes: 3 additions & 3 deletions src/aria2p/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from __future__ import annotations

import json
from typing import Any, Callable, ClassVar, List, Tuple, Union
from typing import Any, Callable, ClassVar, Union

import requests
import websocket
Expand Down Expand Up @@ -50,8 +50,8 @@
NOTIFICATION_BT_COMPLETE,
]

CallsType = List[Tuple[str, List[str], Union[str, int]]]
Multicalls2Type = List[Tuple[str, List[str]]]
CallsType = list[tuple[str, list[str], Union[str, int]]]
Multicalls2Type = list[tuple[str, list[str]]]
CallReturnType = Union[dict, list, str, int]


Expand Down
10 changes: 5 additions & 5 deletions src/aria2p/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import time
from collections import defaultdict
from pathlib import Path
from typing import TYPE_CHECKING, Callable, ClassVar, Sequence, TypedDict
from typing import TYPE_CHECKING, Callable, ClassVar, TypedDict

import pyperclip
import requests
Expand All @@ -32,6 +32,8 @@
from aria2p.utils import get_version, load_configuration

if TYPE_CHECKING:
from collections.abc import Sequence

from aria2p.downloads import Download


Expand Down Expand Up @@ -751,8 +753,7 @@ def process_keyboard_event_main(self, event: KeyboardEvent) -> None: # noqa: D1
if self.focused > 0:
self.focused -= len(self.rows) // 5

if self.focused < 0:
self.focused = 0
self.focused = max(self.focused, 0)
logger.debug(f"Move focus up (step): {self.focused}")

if self.focused < self.row_offset:
Expand All @@ -768,8 +769,7 @@ def process_keyboard_event_main(self, event: KeyboardEvent) -> None: # noqa: D1
if self.focused < len(self.rows) - 1:
self.focused += len(self.rows) // 5

if self.focused > len(self.rows) - 1:
self.focused = len(self.rows) - 1
self.focused = min(self.focused, len(self.rows) - 1)
logger.debug(f"Move focus down (step): {self.focused}")

if self.focused - self.row_offset >= (self.height - 1):
Expand Down
15 changes: 9 additions & 6 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import time
from contextlib import suppress
from pathlib import Path
from typing import Iterator
from typing import TYPE_CHECKING

import psutil
import pytest
Expand All @@ -19,9 +19,12 @@
from aria2p import API, Client, enable_logger
from tests import CONFIGS_DIR, SESSIONS_DIR

if TYPE_CHECKING:
from collections.abc import Iterator


@pytest.fixture(autouse=True)
def tests_logs(request: pytest.FixtureRequest) -> None: # noqa: PT004
def tests_logs(request: pytest.FixtureRequest) -> None:
# put logs in tests/logs
log_path = Path("tests") / "logs"

Expand All @@ -45,8 +48,8 @@ def tests_logs(request: pytest.FixtureRequest) -> None: # noqa: PT004


def spawn_and_wait_server(port: int = 8779) -> subprocess.Popen:
process = subprocess.Popen(
[ # noqa: S603
process = subprocess.Popen( # noqa: S603
[
sys.executable,
"-m",
"uvicorn",
Expand Down Expand Up @@ -287,14 +290,14 @@ def release_port(port_number: int) -> None:
release_lock()


@pytest.fixture()
@pytest.fixture
def port() -> Iterator[int]:
port_number = reserve_port()
yield port_number
release_port(port_number)


@pytest.fixture()
@pytest.fixture
def server(tmp_path: Path, port: int) -> Iterator[Aria2Server]:
with Aria2Server(tmp_path, port) as server:
yield server
Expand Down
5 changes: 4 additions & 1 deletion tests/http_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

from __future__ import annotations

from typing import AsyncIterator
from typing import TYPE_CHECKING

from fastapi import FastAPI
from fastapi.responses import StreamingResponse

if TYPE_CHECKING:
from collections.abc import AsyncIterator


def translate_size(size: str) -> int:
try:
Expand Down

0 comments on commit 1ca3aac

Please sign in to comment.