Skip to content

Commit

Permalink
Fix the ruff errors
Browse files Browse the repository at this point in the history
  • Loading branch information
flacjacket committed Jul 26, 2024
1 parent eaa7ccb commit 48a08a0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 1 addition & 3 deletions pywayland/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
17 changes: 9 additions & 8 deletions pywayland/protocol_core/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down
7 changes: 1 addition & 6 deletions pywayland/scanner/printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}()`"

Expand Down

0 comments on commit 48a08a0

Please sign in to comment.