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 Oct 17, 2024
1 parent 60ba536 commit a212375
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 21 deletions.
2 changes: 1 addition & 1 deletion duties.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def docs(ctx: Context, *cli_args: str, host: str = "127.0.0.1", port: int = 8000


@duty
def docs_deploy(ctx: Context, *, force: bool = False) -> None:
def docs_deploy(ctx: Context, *, force: bool = False) -> None: # noqa: ARG001
"""Deploy the documentation to GitHub pages.
Parameters:
Expand Down
5 changes: 3 additions & 2 deletions src/failprint/capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
import tempfile
from contextlib import contextmanager
from io import StringIO
from typing import IO, TYPE_CHECKING, Iterator, TextIO
from typing import IO, TYPE_CHECKING, TextIO

if TYPE_CHECKING:
from collections.abc import Iterator
from types import TracebackType


Expand Down Expand Up @@ -128,7 +129,7 @@ def __enter__(self) -> CaptureManager: # noqa: PYI034 (false-positive)

# Open devnull if needed.
if self._capture in {Capture.STDOUT, Capture.STDERR}:
self._devnull = open(os.devnull, "w") # noqa: SIM115
self._devnull = open(os.devnull, "w")

# Create temporary file.
# Initially we used a pipe but it would hang on writes given enough output.
Expand Down
5 changes: 4 additions & 1 deletion src/failprint/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@

import argparse
import sys
from typing import Any, Sequence
from typing import TYPE_CHECKING, Any

from failprint import debug
from failprint.capture import Capture
from failprint.formats import accept_custom_format, formats
from failprint.runners import run

if TYPE_CHECKING:
from collections.abc import Sequence


class _DebugInfo(argparse.Action):
def __init__(self, nargs: int | str | None = 0, **kwargs: Any) -> None:
Expand Down
3 changes: 2 additions & 1 deletion src/failprint/formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
from __future__ import annotations

import inspect
from typing import TYPE_CHECKING, Callable, Sequence
from typing import TYPE_CHECKING, Callable

from failprint.lazy import LazyCallable

if TYPE_CHECKING:
from collections.abc import Sequence
from types import FrameType

from failprint.types import CmdFuncType
Expand Down
6 changes: 2 additions & 4 deletions src/failprint/lazy.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,11 @@ def lazy_caller(*args: _P.args, **kwargs: _P.kwargs) -> LazyCallable:


@overload
def lazy(call: Callable[_P, _R], name: str | None = None) -> Callable[_P, LazyCallable]:
... # pragma: no cover
def lazy(call: Callable[_P, _R], name: str | None = None) -> Callable[_P, LazyCallable]: ... # pragma: no cover


@overload
def lazy(call: None = None, name: str | None = None) -> _DecoratorType:
... # pragma: no cover
def lazy(call: None = None, name: str | None = None) -> _DecoratorType: ... # pragma: no cover


def lazy(call: Callable[_P, _R] | None = None, name: str | None = None) -> Callable[_P, LazyCallable] | _DecoratorType:
Expand Down
4 changes: 2 additions & 2 deletions src/failprint/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ def run_subprocess(
if shell and not isinstance(cmd, str):
cmd = printable_command(cmd)

process = subprocess.run(
process = subprocess.run( # noqa: S603
cmd,
input=stdin,
stdout=stdout_opt,
stderr=stderr_opt,
shell=shell, # noqa: S603
shell=shell,
text=True,
encoding="utf8",
check=False,
Expand Down
4 changes: 3 additions & 1 deletion src/failprint/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import sys
import textwrap
import traceback
from typing import TYPE_CHECKING, Callable, Sequence
from typing import TYPE_CHECKING, Callable

import colorama
from ansimarkup import parse
Expand All @@ -19,6 +19,8 @@
from failprint.process import WINDOWS, run_pty_subprocess, run_subprocess

if TYPE_CHECKING:
from collections.abc import Sequence

from failprint.types import CmdFuncType, CmdType

if WINDOWS:
Expand Down
4 changes: 2 additions & 2 deletions src/failprint/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

from __future__ import annotations

from typing import Callable, List, Union
from typing import Callable, Union

from failprint.lazy import LazyCallable

CmdType = Union[str, List[str]]
CmdType = Union[str, list[str]]
CmdFuncType = Union[CmdType, Callable, LazyCallable]

__all__ = ["CmdFuncType", "CmdType"]
5 changes: 4 additions & 1 deletion tests/test_formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

from typing import Callable, Sequence
from typing import TYPE_CHECKING, Callable

import pytest
from hypothesis import given
Expand All @@ -11,6 +11,9 @@
from failprint.formats import DEFAULT_CALLABLE_NAME, GT, LT, _get_callable_name, printable_command
from failprint.runners import run

if TYPE_CHECKING:
from collections.abc import Sequence


@pytest.mark.parametrize(
("cmd", "expected"),
Expand Down
9 changes: 3 additions & 6 deletions tests/test_lazy.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@ def test_decorating_function() -> None:
"""Test our `lazy` decorator."""

@lazy
def greet() -> None:
... # pragma: no cover
def greet() -> None: ... # pragma: no cover

non_lazy = greet()
assert isinstance(non_lazy, LazyCallable)
assert not non_lazy.name

@lazy(name="lazy_greet")
def greet2() -> None:
... # pragma: no cover
def greet2() -> None: ... # pragma: no cover

non_lazy = greet2()
assert isinstance(non_lazy, LazyCallable)
Expand All @@ -26,8 +24,7 @@ def greet2() -> None:
def test_lazifying_function() -> None:
"""Test our `lazy` decorator as a function."""

def greet() -> None:
... # pragma: no cover
def greet() -> None: ... # pragma: no cover

lazy_greet = lazy(greet)
non_lazy = lazy_greet()
Expand Down

0 comments on commit a212375

Please sign in to comment.