From f07ead4c9aee1fb9f76a87a052be018299f796ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Robert?= Date: Sun, 1 Sep 2024 09:30:34 +0200 Subject: [PATCH] DEP: drop support for Python 3.9 --- .github/workflows/ci.yml | 6 +++--- pyproject.toml | 4 ++-- src/idefix_cli/__main__.py | 4 ++-- src/idefix_cli/_commands/digest.py | 8 ++++---- src/idefix_cli/lib.py | 3 ++- tests/test_ux.py | 10 ++-------- 6 files changed, 15 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a34781b..d3e14cb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: - macos-latest - windows-latest python-version: - - '3.9' + - '3.10' - '3.12' free-threading: - false @@ -62,7 +62,7 @@ jobs: strategy: matrix: python-version: - - '3.9' + - '3.10' - '3.12' runs-on: ubuntu-latest @@ -86,7 +86,7 @@ jobs: strategy: matrix: python-version: - - '3.9' + - '3.10' - '3.12' runs-on: ubuntu-latest diff --git a/pyproject.toml b/pyproject.toml index 3c17fba..c6a8cac 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,7 @@ classifiers = [ "Programming Language :: Python :: 3", "Typing :: Typed", ] -requires-python = ">=3.9" +requires-python = ">=3.10" dependencies = [ "inifix>=4.2.2", "packaging>=21.0", @@ -77,7 +77,7 @@ combine-as-imports = true known-first-party = ["idefix_cli"] [tool.mypy] -python_version = 3.9 +python_version = '3.10' show_error_codes = true warn_unused_configs = true warn_unused_ignores = true diff --git a/src/idefix_cli/__main__.py b/src/idefix_cli/__main__.py index 11ce553..bc0388c 100644 --- a/src/idefix_cli/__main__.py +++ b/src/idefix_cli/__main__.py @@ -6,7 +6,7 @@ from importlib.util import module_from_spec, spec_from_file_location from pathlib import Path from types import FunctionType, ModuleType -from typing import Any, Final, Optional +from typing import Any, Final from idefix_cli import __version__ from idefix_cli._theme import set_theme @@ -94,7 +94,7 @@ def _setup_commands(parser: ArgumentParser) -> CommandMap: f"command plugin {command_name} is missing a module docstring" ) - usage: Optional[str] + usage: str | None help, _, usage = module.__doc__.strip().partition("\n") usage = usage or None sub_parser = sparsers.add_parser( diff --git a/src/idefix_cli/_commands/digest.py b/src/idefix_cli/_commands/digest.py index 1fad4cb..136662f 100644 --- a/src/idefix_cli/_commands/digest.py +++ b/src/idefix_cli/_commands/digest.py @@ -5,7 +5,7 @@ from argparse import ArgumentParser from pathlib import Path from time import monotonic_ns -from typing import Any, Optional +from typing import Any from idefix_cli.lib import print_error @@ -84,7 +84,7 @@ def add_arguments(parser: ArgumentParser) -> None: def command( dir: str, - input_: Optional[list[str]] = None, + input_: list[str] | None = None, output=sys.stdout, all_files: bool = False, timeit: bool = False, @@ -135,13 +135,13 @@ def command( header = data[0][0] # first line captured from the first log file if len(data) > 1: - for p, c in zip(log_files[1:], data[1:]): + for p, c in zip(log_files[1:], data[1:], strict=False): if c[0] != header: # pragma: no cover print_error(f"header mismatch from {p} and {log_files[0]}") return 1 final_result: list[str] = [] - for p, d in zip(log_files, data): + for p, d in zip(log_files, data, strict=False): columns = _log_to_data(d) final_result.append(_data_to_json(p.name, columns)) diff --git a/src/idefix_cli/lib.py b/src/idefix_cli/lib.py index a9b8e87..4353007 100644 --- a/src/idefix_cli/lib.py +++ b/src/idefix_cli/lib.py @@ -5,13 +5,14 @@ import re import sys import warnings +from collections.abc import Callable from configparser import ConfigParser from functools import wraps from glob import glob from itertools import chain from pathlib import Path from textwrap import indent -from typing import Any, Callable, TypeVar, cast +from typing import Any, TypeVar, cast from packaging.version import Version from termcolor import cprint diff --git a/tests/test_ux.py b/tests/test_ux.py index f55db65..598e6e4 100644 --- a/tests/test_ux.py +++ b/tests/test_ux.py @@ -1,18 +1,12 @@ -import sys - import pytest from pytest_check import check from idefix_cli.__main__ import main -if sys.version_info >= (3, 10): - OPTIONAL_SEC = "options" -else: - OPTIONAL_SEC = "optional arguments" HELP_MESSAGE = ( "usage: idfx [-h] [-v] {clean,clone,conf,digest,read,run,switch,write} ...\n" "\n" - f"{OPTIONAL_SEC}:\n" + "options:\n" " -h, --help show this help message and exit\n" " -v, --version show program's version number and exit\n" "\n" @@ -32,7 +26,7 @@ def get_lines(help_message: str) -> list[str]: # skip the first lines because they differ between macos and linux lines = iter(help_message.splitlines()) - while not next(lines).startswith(OPTIONAL_SEC): + while not next(lines).startswith("options:"): continue return list(lines)