From f6e2c11eb85c946187dc04bea604e4c8c4e8fbe0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Mon, 2 Sep 2024 16:22:10 +0200 Subject: [PATCH] add SLF lint --- pkgs/clan-app/clan_app/api/__init__.py | 2 +- pkgs/clan-app/clan_app/views/webview.py | 2 +- pkgs/clan-cli/clan_cli/__init__.py | 4 ++-- pkgs/clan-cli/docs.py | 14 +++++++------- .../clan_vm_manager/singletons/use_join.py | 4 ++-- .../moonlight_sunshine_accept/sunshine/api.py | 6 ++++-- .../moonlight_sunshine_accept/sunshine/config.py | 5 +---- pyproject.toml | 1 + 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/pkgs/clan-app/clan_app/api/__init__.py b/pkgs/clan-app/clan_app/api/__init__.py index 602532e65..b1c3418a4 100644 --- a/pkgs/clan-app/clan_app/api/__init__.py +++ b/pkgs/clan-app/clan_app/api/__init__.py @@ -50,7 +50,7 @@ class ImplFunc(GObject.Object, Generic[P, B]): msg = "Method 'async_run' must be implemented" raise NotImplementedError(msg) - def _async_run(self, data: Any) -> bool: + def internal_async_run(self, data: Any) -> bool: result = GLib.SOURCE_REMOVE try: result = self.async_run(**data) diff --git a/pkgs/clan-app/clan_app/views/webview.py b/pkgs/clan-app/clan_app/views/webview.py index f6e754b08..2500b2391 100644 --- a/pkgs/clan-app/clan_app/views/webview.py +++ b/pkgs/clan-app/clan_app/views/webview.py @@ -118,7 +118,7 @@ class WebExecutor(GObject.Object): # from_dict really takes Anything and returns an instance of the type/class reconciled_arguments[k] = from_dict(arg_class, v) - GLib.idle_add(fn_instance._async_run, reconciled_arguments) + GLib.idle_add(fn_instance.internal_async_run, reconciled_arguments) def on_result(self, source: ImplFunc, data: GResult) -> None: result = dataclass_to_dict(data.result) diff --git a/pkgs/clan-cli/clan_cli/__init__.py b/pkgs/clan-cli/clan_cli/__init__.py index c2124e39e..7ab89cce6 100644 --- a/pkgs/clan-cli/clan_cli/__init__.py +++ b/pkgs/clan-cli/clan_cli/__init__.py @@ -83,8 +83,8 @@ def add_common_flags(parser: argparse.ArgumentParser) -> None: def register_common_flags(parser: argparse.ArgumentParser) -> None: has_subparsers = False - for action in parser._actions: - if isinstance(action, argparse._SubParsersAction): + for action in parser._actions: # noqa: SLF001 + if isinstance(action, argparse._SubParsersAction): # noqa: SLF001 for _choice, child_parser in action.choices.items(): has_subparsers = True register_common_flags(child_parser) diff --git a/pkgs/clan-cli/docs.py b/pkgs/clan-cli/docs.py index 7f9118424..b94e5d218 100644 --- a/pkgs/clan-cli/docs.py +++ b/pkgs/clan-cli/docs.py @@ -174,12 +174,12 @@ def get_subcommands( positional_options: list[Option] = [] subcommands: list[Subcommand] = [] - for action in parser._actions: - if isinstance(action, argparse._HelpAction): + for action in parser._actions: # noqa: SLF001 + if isinstance(action, argparse._HelpAction): # noqa: SLF001 # Pseudoaction that holds the help message continue - if isinstance(action, argparse._SubParsersAction): + if isinstance(action, argparse._SubParsersAction): # noqa: SLF001 continue # Subparsers handled separately option_strings = ", ".join(action.option_strings) @@ -204,8 +204,8 @@ def get_subcommands( ) ) - for action in parser._actions: - if isinstance(action, argparse._SubParsersAction): + for action in parser._actions: # noqa: SLF001 + if isinstance(action, argparse._SubParsersAction): # noqa: SLF001 subparsers: dict[str, argparse.ArgumentParser] = action.choices for name, subparser in subparsers.items(): @@ -252,8 +252,8 @@ def collect_commands() -> list[Category]: result: list[Category] = [] - for action in parser._actions: - if isinstance(action, argparse._SubParsersAction): + for action in parser._actions: # noqa: SLF001 + if isinstance(action, argparse._SubParsersAction): # noqa: SLF001 subparsers: dict[str, argparse.ArgumentParser] = action.choices for name, subparser in subparsers.items(): if str(subparser.description).startswith("WIP"): diff --git a/pkgs/clan-vm-manager/clan_vm_manager/singletons/use_join.py b/pkgs/clan-vm-manager/clan_vm_manager/singletons/use_join.py index ba59297ea..1d720f978 100644 --- a/pkgs/clan-vm-manager/clan_vm_manager/singletons/use_join.py +++ b/pkgs/clan-vm-manager/clan_vm_manager/singletons/use_join.py @@ -64,11 +64,11 @@ class JoinList: cls._instance = cls.__new__(cls) cls.list_store = Gio.ListStore.new(JoinValue) - ClanStore.use().register_on_deep_change(cls._instance._rerender_join_list) + ClanStore.use().register_on_deep_change(cls._instance.rerender_join_list) return cls._instance - def _rerender_join_list( + def rerender_join_list( self, source: GKVStore, position: int, removed: int, added: int ) -> None: self.list_store.items_changed( diff --git a/pkgs/moonlight-sunshine-accept/moonlight_sunshine_accept/sunshine/api.py b/pkgs/moonlight-sunshine-accept/moonlight_sunshine_accept/sunshine/api.py index a44109ed7..206f0d6fb 100644 --- a/pkgs/moonlight-sunshine-accept/moonlight_sunshine_accept/sunshine/api.py +++ b/pkgs/moonlight-sunshine-accept/moonlight_sunshine_accept/sunshine/api.py @@ -12,7 +12,7 @@ def get_context() -> http.client.ssl.SSLContext: # certfile="/home/kenji/.config/sunshine/credentials/cacert.pem", # keyfile="/home/kenji/.config/sunshine/credentials/cakey.pem", # ) - return http.client.ssl._create_unverified_context() + return http.client.ssl._create_unverified_context() # noqa: SLF001 def pair(pin: str) -> str: @@ -42,7 +42,9 @@ def pair(pin: str) -> str: def restart() -> None: # Define the connection conn = http.client.HTTPSConnection( - "localhost", 47990, context=http.client.ssl._create_unverified_context() + "localhost", + 47990, + context=http.client.ssl._create_unverified_context(), # noqa: SLF001 ) user_and_pass = base64.b64encode(b"sunshine:sunshine").decode("ascii") headers = { diff --git a/pkgs/moonlight-sunshine-accept/moonlight_sunshine_accept/sunshine/config.py b/pkgs/moonlight-sunshine-accept/moonlight_sunshine_accept/sunshine/config.py index d4dc10eb5..55a088e12 100644 --- a/pkgs/moonlight-sunshine-accept/moonlight_sunshine_accept/sunshine/config.py +++ b/pkgs/moonlight-sunshine-accept/moonlight_sunshine_accept/sunshine/config.py @@ -19,16 +19,13 @@ class Config: cls._instance = super().__new__(cls) cls._instance.config = configparser.ConfigParser() config = config_location or cls._instance.default_sunshine_config_file() - cls._instance._config_location = config + cls._instance.config_location = config with open(config) as f: config_string = f"[{PSEUDO_SECTION}]\n" + f.read() print(config_string) cls._instance.config.read_string(config_string) return cls._instance - def config_location(self) -> str: - return self._config_location - def default_sunshine_config_dir(self) -> str: return os.path.join(os.path.expanduser("~"), ".config", "sunshine") diff --git a/pyproject.toml b/pyproject.toml index 019beab42..a1c7021ab 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,6 +33,7 @@ lint.select = [ "RET", "RSE", "RUF", + "SLF", "T10", "TID", "U",