From 48a08a01c9df18d48764663d0e636002c5bbfc5e Mon Sep 17 00:00:00 2001 From: Sean Vig Date: Thu, 25 Jul 2024 22:19:54 -0400 Subject: [PATCH] Fix the ruff errors --- .pre-commit-config.yaml | 4 ++-- pywayland/__init__.py | 4 +--- pywayland/protocol_core/message.py | 17 +++++++++-------- pywayland/scanner/printer.py | 7 +------ 4 files changed, 13 insertions(+), 19 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index decb927..2f3ce87 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,12 +1,12 @@ repos: - repo: https://github.com/psf/black - rev: 23.9.0 + rev: 24.4.2 hooks: - id: black # Use the latest supported version here language_version: python3.11 exclude: ^test/scanner_files/ - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.287 + rev: v0.5.5 hooks: - id: ruff diff --git a/pywayland/__init__.py b/pywayland/__init__.py index f88957d..8243932 100644 --- a/pywayland/__init__.py +++ b/pywayland/__init__.py @@ -21,6 +21,4 @@ "No module named pywayland._ffi, be sure to run `python ./pywayland/ffi_build.py`" ) -__wayland_version__ = "{}.{}.{}".format( - lib.WAYLAND_VERSION_MAJOR, lib.WAYLAND_VERSION_MINOR, lib.WAYLAND_VERSION_MICRO -) +__wayland_version__ = f"{lib.WAYLAND_VERSION_MAJOR}.{lib.WAYLAND_VERSION_MINOR}.{lib.WAYLAND_VERSION_MICRO}" diff --git a/pywayland/protocol_core/message.py b/pywayland/protocol_core/message.py index 60213f5..2fbfe0d 100644 --- a/pywayland/protocol_core/message.py +++ b/pywayland/protocol_core/message.py @@ -14,8 +14,8 @@ from __future__ import annotations -from typing import Callable, Iterable from operator import attrgetter +from typing import Callable, Iterable from weakref import WeakKeyDictionary from pywayland import ffi, lib @@ -130,9 +130,7 @@ def c_to_arguments(self, args_ptr): elif argument.argument_type == ArgumentType.Object: if arg_ptr.o == ffi.NULL: if not argument.nullable: - message = "Got null object parsing arguments for '{}' message, may already be destroyed".format( - self.name - ) + message = f"Got null object parsing arguments for '{self.name}' message, may already be destroyed" raise RuntimeError(message) args.append(None) else: @@ -141,14 +139,17 @@ def c_to_arguments(self, args_ptr): obj = iface.registry.get(proxy_ptr) if obj is None: raise RuntimeError( - "Unable to get object for {}, was it garbage collected?".format( - proxy_ptr - ) + f"Unable to get object for {proxy_ptr}, was it garbage collected?" ) args.append(obj) elif argument.argument_type == ArgumentType.NewId: from pywayland.protocol.wayland.wl_registry import WlRegistry - if (display := next(map(attrgetter("_display"), WlRegistry.registry.values()), None)) is None: + + if ( + display := next( + map(attrgetter("_display"), WlRegistry.registry.values()), None + ) + ) is None: raise RuntimeError("Cannot find display") iface = argument.interface assert iface diff --git a/pywayland/scanner/printer.py b/pywayland/scanner/printer.py index e2d38f8..0cebc55 100644 --- a/pywayland/scanner/printer.py +++ b/pywayland/scanner/printer.py @@ -206,12 +206,7 @@ def _doc_funcs_replace(self, match: Match) -> str: and interface_name in self._interface_imports ): protocol_path = self._interface_imports[interface_name] - return ":func:`{class_name}{func}() <{base_path}.{iface}.{class_name}{func}>`".format( - class_name=interface_class, - func=function_name, - base_path=BASE_PATH, - iface=protocol_path, - ) + return f":func:`{interface_class}{function_name}() <{BASE_PATH}.{protocol_path}.{interface_class}{function_name}>`" return f"`{interface_class}{function_name}()`"