diff --git a/pyproject.toml b/pyproject.toml index 9bbadd00..505fe38c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -73,7 +73,7 @@ mss = "mss.__main__:main" dev = [ "build==1.3.0", "mypy==1.17.1", - "ruff==0.11.11", + "ruff==0.12.9", "twine==6.1.0", ] docs = [ diff --git a/src/mss/factory.py b/src/mss/factory.py index b0793e8c..29cb3ed1 100644 --- a/src/mss/factory.py +++ b/src/mss/factory.py @@ -22,17 +22,17 @@ def mss(**kwargs: Any) -> MSSBase: os_ = platform.system().lower() if os_ == "darwin": - from mss import darwin + from mss import darwin # noqa: PLC0415 return darwin.MSS(**kwargs) if os_ == "linux": - from mss import linux + from mss import linux # noqa: PLC0415 return linux.MSS(**kwargs) if os_ == "windows": - from mss import windows + from mss import windows # noqa: PLC0415 return windows.MSS(**kwargs) diff --git a/src/tests/test_implementation.py b/src/tests/test_implementation.py index 294ccc80..84d8594f 100644 --- a/src/tests/test_implementation.py +++ b/src/tests/test_implementation.py @@ -5,9 +5,10 @@ from __future__ import annotations import os -import os.path import platform import sys +import threading +import time from datetime import datetime from pathlib import Path from typing import TYPE_CHECKING @@ -16,7 +17,6 @@ import pytest import mss -import mss.tools from mss.__main__ import main as entry_point from mss.base import MSSBase from mss.exception import ScreenShotError @@ -237,8 +237,6 @@ def test_grab_with_tuple_percents() -> None: def test_thread_safety() -> None: """Regression test for issue #169.""" - import threading - import time def record(check: dict) -> None: """Record for one second.""" diff --git a/src/tests/test_leaks.py b/src/tests/test_leaks.py index f27e7f77..7e04fb34 100644 --- a/src/tests/test_leaks.py +++ b/src/tests/test_leaks.py @@ -2,8 +2,10 @@ Source: https://github.com/BoboTiG/python-mss. """ +import ctypes import os import platform +import subprocess from collections.abc import Callable import pytest @@ -18,8 +20,6 @@ def get_opened_socket() -> int: """GNU/Linux: a way to get the opened sockets count. It will be used to check X server connections are well closed. """ - import subprocess - cmd = f"lsof -U | grep {PID}" output = subprocess.check_output(cmd, shell=True) return len(output.splitlines()) @@ -29,8 +29,6 @@ def get_handles() -> int: """Windows: a way to get the GDI handles count. It will be used to check the handles count is not growing, showing resource leaks. """ - import ctypes - PROCESS_QUERY_INFORMATION = 0x400 # noqa:N806 GR_GDIOBJECTS = 0 # noqa:N806 h = ctypes.windll.kernel32.OpenProcess(PROCESS_QUERY_INFORMATION, 0, PID) diff --git a/src/tests/test_setup.py b/src/tests/test_setup.py index d4788677..da55637c 100644 --- a/src/tests/test_setup.py +++ b/src/tests/test_setup.py @@ -17,9 +17,9 @@ pytest.importorskip("build") pytest.importorskip("twine") -SDIST = "python -m build --sdist".split() -WHEEL = "python -m build --wheel".split() -CHECK = "twine check --strict".split() +SDIST = ["python", "-m", "build", "--sdist"] +WHEEL = ["python", "-m", "build", "--wheel"] +CHECK = ["twine", "check", "--strict"] def test_sdist() -> None: