diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5606881..c066aff 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,11 +66,11 @@ jobs: fail-fast: false matrix: python-version: - - "3.9" - "3.10" - "3.11" - "3.12" - "3.13" + - "3.14" - "pypy-3.11" wayland-version: ["1.24.0"] wayland-protocols-version: ["1.45"] @@ -91,13 +91,13 @@ jobs: echo "XDG_RUNTIME_DIR=/tmp" >> $GITHUB_ENV - name: Install Python dependencies run: | - pip install "setuptools>=77.0.0" - pip install -r requirements.txt - pip install -r requirements-dev.txt + pip install .[ci] python pywayland/ffi_build.py python -m pywayland.scanner --with-protocols - name: Run unit tests - run: pytest --cov pywayland --cov-report term-missing + run: | + pip install .[test] + pytest --cov pywayland --cov-report term-missing - name: Push coverage run: coveralls --service=github env: @@ -119,7 +119,7 @@ jobs: runs-on: ubuntu-24.04 needs: build-wayland env: - python-version: "3.13" + python-version: "3.14" wayland-version: "1.24.0" wayland-protocols-version: "1.45" steps: @@ -139,36 +139,19 @@ jobs: echo "XDG_RUNTIME_DIR=/tmp" >> $GITHUB_ENV - name: Install Python dependencies run: | - pip install "setuptools>=77.0.0" - pip install -r requirements.txt - pip install -r doc/requirements.txt + pip install .[ci] python pywayland/ffi_build.py python -m pywayland.scanner --with-protocols - name: Build docs - run: sphinx-build -W -b html doc doc/_build/html - ruff-test: - name: ruff test - runs-on: ubuntu-24.04 - env: - python-version: "3.13" - wayland-version: "1.24.0" - wayland-protocols-version: "1.45" - steps: - - uses: actions/checkout@v4 - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: ${{ env.python-version }} - - name: Run ruff check - uses: astral-sh/ruff-action@v3 - with: - src: pywayland - mypy-test: - name: mypy test + run: | + pip install .[docs] + sphinx-build -W -b html doc doc/_build/html + pre-commit-test: + name: pre-commit test runs-on: ubuntu-24.04 needs: build-wayland env: - python-version: "3.13" + python-version: "3.14" wayland-version: "1.24.0" wayland-protocols-version: "1.45" steps: @@ -188,19 +171,17 @@ jobs: echo "XDG_RUNTIME_DIR=/tmp" >> $GITHUB_ENV - name: Install Python dependencies run: | - pip install "setuptools>=77.0.0" - pip install -r requirements.txt - pip install -r requirements-types.txt + pip install .[ci] python pywayland/ffi_build.py python -m pywayland.scanner --with-protocols - - name: Run mypy test - run: mypy -p pywayland + - name: Run pre-commit test + uses: pre-commit/action@v3.0.1 packaging-test: name: packaging test runs-on: ubuntu-24.04 needs: build-wayland env: - python-version: "3.13" + python-version: "3.14" wayland-version: "1.24.0" wayland-protocols-version: "1.45" steps: @@ -220,12 +201,12 @@ jobs: echo "XDG_RUNTIME_DIR=/tmp" >> $GITHUB_ENV - name: Install Python dependencies run: | - pip install "setuptools>=77.0.0" - pip install -r requirements.txt - pip install build check-manifest twine + pip install .[ci] python pywayland/ffi_build.py + python -m pywayland.scanner --with-protocols - name: Run packaging test run: | + pip install .[packaging] check-manifest python setup.py check -m -s python -m build --sdist diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b7ceb15..724f977 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,9 +11,9 @@ jobs: runs-on: ubuntu-24.04 container: quay.io/pypa/manylinux_2_34_x86_64 env: + python-version: "3.14" wayland-version: "1.24.0" wayland-protocols-version: "1.45" - python-version: "3.13" steps: - name: Install dependencies run: | @@ -76,7 +76,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] + python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"] steps: - name: Download wayland libraries uses: actions/download-artifact@v4 @@ -154,11 +154,11 @@ jobs: fail-fast: false matrix: python-version: - - "3.9" - "3.10" - "3.11" - "3.12" - "3.13" + - "3.14" - "pypy-3.11" steps: - name: Download wheels @@ -182,7 +182,7 @@ jobs: container: quay.io/pypa/manylinux_2_34_x86_64 needs: build-wayland env: - python-version: "3.13" + python-version: "3.14" steps: - name: Download wayland libraries uses: actions/download-artifact@v4 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ee04219..849122d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,12 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.13.0 + rev: v0.14.4 hooks: - id: ruff-check + args: [--fix] - id: ruff-format + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v1.18.2 + hooks: + - id: mypy + files: "^(pywayland|example)\/.*" diff --git a/doc/conf.py b/doc/conf.py index d1924a1..aa25a9c 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -2,14 +2,14 @@ import importlib import os +import re import shutil import sys -import re # -- Mock necessary classes ----------------------------------------------- from unittest.mock import MagicMock -import sphinx_rtd_theme +import sphinx_rtd_theme # noqa: F401 sys.path.insert(0, os.path.abspath(".")) sys.path.insert(0, os.path.abspath("..")) @@ -18,9 +18,13 @@ sys.modules.update((mod_name, MagicMock()) for mod_name in MOCK_MODULES) # -- Build pywayland.protocol w/docs -------------------------------------- -from protocol_build import protocols_build, protocols_version, wayland_version +from protocol_build import ( # noqa: E402 + protocols_build, + protocols_version, + wayland_version, +) -from pywayland import __version__ +from pywayland import __version__ # noqa: E402 protocol_build_dir = "../pywayland/protocol/" protocol_doc_dir = "module/protocol" diff --git a/doc/requirements.txt b/doc/requirements.txt deleted file mode 100644 index 8213302..0000000 --- a/doc/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -sphinx -sphinx_rtd_theme diff --git a/pyproject.toml b/pyproject.toml index 5a9ca63..7fe02d0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ build-backend = "setuptools.build_meta" name = "pywayland" description = "Python bindings for the libwayland library written in pure Python" authors = [{name = "Sean Vig", email = "sean.v.775@gmail.com"}] -requires-python = ">=3.9" +requires-python = ">=3.10" license = "Apache-2.0" readme = "README.rst" classifiers = [ @@ -18,11 +18,11 @@ classifiers = [ "Operating System :: POSIX", "Operating System :: POSIX :: Linux", "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Desktop Environment :: Window Managers", @@ -40,7 +40,22 @@ source = "https://github.com/flacjacket/pywayland" issues = "https://github.com/flacjacket/pywayland/issues" [project.optional-dependencies] -test = ["pytest"] +ci = ["setuptools>=77.0.0"] +test = [ + "pytest", + "pytest-cov", + "coverage>=6.5.0", + "coveralls>=3.3.1", +] +docs = [ + "sphinx", + "sphinx_rtd_theme", +] +packaging = [ + "build", + "check-manifest", + "twine", +] [project.scripts] pywayland-scanner = "pywayland.scanner.__main__:main" @@ -78,6 +93,7 @@ ignore = [ ] [tool.mypy] +packages = ["pywayland", "example"] warn_unused_configs = true warn_redundant_casts = true warn_unused_ignores = true diff --git a/pywayland/_ffi/ffi.pyi b/pywayland/_ffi/ffi.pyi index 2c86c97..848976a 100644 --- a/pywayland/_ffi/ffi.pyi +++ b/pywayland/_ffi/ffi.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, Self, TypeVar, overload +from collections.abc import Callable +from typing import Any, Self, TypeVar, overload class CData: def __getitem__(self, idx: int) -> Self: ... diff --git a/pywayland/client/display.py b/pywayland/client/display.py index b158b26..4be6eda 100644 --- a/pywayland/client/display.py +++ b/pywayland/client/display.py @@ -23,9 +23,7 @@ if TYPE_CHECKING: from types import TracebackType - from typing import Any - - from typing_extensions import Literal + from typing import Any, Literal from pywayland.client.eventqueue import EventQueue from pywayland.protocol_core import Proxy diff --git a/pywayland/dispatcher.py b/pywayland/dispatcher.py index 7f89f06..683607c 100644 --- a/pywayland/dispatcher.py +++ b/pywayland/dispatcher.py @@ -15,14 +15,15 @@ from __future__ import annotations import traceback -from typing import TYPE_CHECKING, Callable, Optional +from collections.abc import Callable +from typing import TYPE_CHECKING from pywayland import ffi, lib if TYPE_CHECKING: from pywayland.protocol_core.message import Message -CallbackT = Callable[..., Optional[int]] +CallbackT = Callable[..., int | None] # int (*wl_dispatcher_func_t)(const void *, void *, uint32_t, const struct wl_message *, union wl_argument *) diff --git a/pywayland/protocol_core/interface.py b/pywayland/protocol_core/interface.py index bb12305..a16a1da 100644 --- a/pywayland/protocol_core/interface.py +++ b/pywayland/protocol_core/interface.py @@ -22,7 +22,8 @@ from .message import Message if TYPE_CHECKING: - from typing import Any, Callable + from collections.abc import Callable + from typing import Any from .argument import Argument from .globals import Global diff --git a/pywayland/protocol_core/message.py b/pywayland/protocol_core/message.py index b13dbf6..7271f52 100644 --- a/pywayland/protocol_core/message.py +++ b/pywayland/protocol_core/message.py @@ -23,8 +23,8 @@ from .argument import Argument, ArgumentType if TYPE_CHECKING: - from collections.abc import Iterable - from typing import Any, Callable + from collections.abc import Callable, Iterable + from typing import Any from pywayland.protocol_core import Proxy diff --git a/pywayland/server/display.py b/pywayland/server/display.py index f8f3099..221e5b7 100644 --- a/pywayland/server/display.py +++ b/pywayland/server/display.py @@ -23,8 +23,7 @@ if TYPE_CHECKING: from types import TracebackType - - from typing_extensions import Literal + from typing import Literal from pywayland.protocol.wayland import WlShm diff --git a/pywayland/server/listener.py b/pywayland/server/listener.py index f870d1f..c031391 100644 --- a/pywayland/server/listener.py +++ b/pywayland/server/listener.py @@ -21,7 +21,8 @@ from pywayland.utils import wl_container_of if TYPE_CHECKING: - from typing import Any, Callable + from collections.abc import Callable + from typing import Any logger = getLogger(__package__) diff --git a/pywayland/utils.py b/pywayland/utils.py index 1e0899d..d06af00 100644 --- a/pywayland/utils.py +++ b/pywayland/utils.py @@ -22,9 +22,9 @@ from . import ffi, lib if TYPE_CHECKING: - from collections.abc import Iterator + from collections.abc import Callable, Iterator from types import TracebackType - from typing import Any, Callable + from typing import Any def ensure_valid(func: Callable[..., Any]) -> Callable[..., Any]: diff --git a/requirements-dev.txt b/requirements-dev.txt deleted file mode 100644 index 0e21b93..0000000 --- a/requirements-dev.txt +++ /dev/null @@ -1,5 +0,0 @@ -# testing/CI libraries -pytest -pytest-cov -coverage>=6.5.0 -coveralls>=3.3.1 diff --git a/requirements-types.txt b/requirements-types.txt deleted file mode 100644 index 327839b..0000000 --- a/requirements-types.txt +++ /dev/null @@ -1,2 +0,0 @@ -mypy -types-dataclasses diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 7f4ce8f..0000000 --- a/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -cffi>=1.12.0 diff --git a/test/test_client_destroy.py b/test/test_client_destroy.py index 8acfdc6..90a54a0 100644 --- a/test/test_client_destroy.py +++ b/test/test_client_destroy.py @@ -31,7 +31,7 @@ def destroy_notify_b(*args): def test_client_destroy_listener(): global a, b - s1, s2 = socket.socketpair(socket.AF_UNIX, socket.SOCK_STREAM, 0) + s1, s2 = socket.socketpair(socket.AF_UNIX, socket.SOCK_STREAM, 0) # noqa: RUF059 a = 0 b = 0 diff --git a/test/test_registry_query.py b/test/test_registry_query.py index 695fbab..8abcb17 100644 --- a/test/test_registry_query.py +++ b/test/test_registry_query.py @@ -67,7 +67,7 @@ def test_get_registry(): s = ServerDisplay() # Add a compositor so we can query for it (and keep it alive) - compositor = WlCompositor.global_class(s) + compositor = WlCompositor.global_class(s) # noqa: F841 # Add a timer to kill the server after 0.5 sec (should be more than enough # time, don't know a more deterministic way...)