add SLF lint
This commit is contained in:
@@ -50,7 +50,7 @@ class ImplFunc(GObject.Object, Generic[P, B]):
|
|||||||
msg = "Method 'async_run' must be implemented"
|
msg = "Method 'async_run' must be implemented"
|
||||||
raise NotImplementedError(msg)
|
raise NotImplementedError(msg)
|
||||||
|
|
||||||
def _async_run(self, data: Any) -> bool:
|
def internal_async_run(self, data: Any) -> bool:
|
||||||
result = GLib.SOURCE_REMOVE
|
result = GLib.SOURCE_REMOVE
|
||||||
try:
|
try:
|
||||||
result = self.async_run(**data)
|
result = self.async_run(**data)
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ class WebExecutor(GObject.Object):
|
|||||||
# from_dict really takes Anything and returns an instance of the type/class
|
# from_dict really takes Anything and returns an instance of the type/class
|
||||||
reconciled_arguments[k] = from_dict(arg_class, v)
|
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:
|
def on_result(self, source: ImplFunc, data: GResult) -> None:
|
||||||
result = dataclass_to_dict(data.result)
|
result = dataclass_to_dict(data.result)
|
||||||
|
|||||||
@@ -83,8 +83,8 @@ def add_common_flags(parser: argparse.ArgumentParser) -> None:
|
|||||||
|
|
||||||
def register_common_flags(parser: argparse.ArgumentParser) -> None:
|
def register_common_flags(parser: argparse.ArgumentParser) -> None:
|
||||||
has_subparsers = False
|
has_subparsers = False
|
||||||
for action in parser._actions:
|
for action in parser._actions: # noqa: SLF001
|
||||||
if isinstance(action, argparse._SubParsersAction):
|
if isinstance(action, argparse._SubParsersAction): # noqa: SLF001
|
||||||
for _choice, child_parser in action.choices.items():
|
for _choice, child_parser in action.choices.items():
|
||||||
has_subparsers = True
|
has_subparsers = True
|
||||||
register_common_flags(child_parser)
|
register_common_flags(child_parser)
|
||||||
|
|||||||
@@ -174,12 +174,12 @@ def get_subcommands(
|
|||||||
positional_options: list[Option] = []
|
positional_options: list[Option] = []
|
||||||
subcommands: list[Subcommand] = []
|
subcommands: list[Subcommand] = []
|
||||||
|
|
||||||
for action in parser._actions:
|
for action in parser._actions: # noqa: SLF001
|
||||||
if isinstance(action, argparse._HelpAction):
|
if isinstance(action, argparse._HelpAction): # noqa: SLF001
|
||||||
# Pseudoaction that holds the help message
|
# Pseudoaction that holds the help message
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if isinstance(action, argparse._SubParsersAction):
|
if isinstance(action, argparse._SubParsersAction): # noqa: SLF001
|
||||||
continue # Subparsers handled separately
|
continue # Subparsers handled separately
|
||||||
|
|
||||||
option_strings = ", ".join(action.option_strings)
|
option_strings = ", ".join(action.option_strings)
|
||||||
@@ -204,8 +204,8 @@ def get_subcommands(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
for action in parser._actions:
|
for action in parser._actions: # noqa: SLF001
|
||||||
if isinstance(action, argparse._SubParsersAction):
|
if isinstance(action, argparse._SubParsersAction): # noqa: SLF001
|
||||||
subparsers: dict[str, argparse.ArgumentParser] = action.choices
|
subparsers: dict[str, argparse.ArgumentParser] = action.choices
|
||||||
|
|
||||||
for name, subparser in subparsers.items():
|
for name, subparser in subparsers.items():
|
||||||
@@ -252,8 +252,8 @@ def collect_commands() -> list[Category]:
|
|||||||
|
|
||||||
result: list[Category] = []
|
result: list[Category] = []
|
||||||
|
|
||||||
for action in parser._actions:
|
for action in parser._actions: # noqa: SLF001
|
||||||
if isinstance(action, argparse._SubParsersAction):
|
if isinstance(action, argparse._SubParsersAction): # noqa: SLF001
|
||||||
subparsers: dict[str, argparse.ArgumentParser] = action.choices
|
subparsers: dict[str, argparse.ArgumentParser] = action.choices
|
||||||
for name, subparser in subparsers.items():
|
for name, subparser in subparsers.items():
|
||||||
if str(subparser.description).startswith("WIP"):
|
if str(subparser.description).startswith("WIP"):
|
||||||
|
|||||||
@@ -64,11 +64,11 @@ class JoinList:
|
|||||||
cls._instance = cls.__new__(cls)
|
cls._instance = cls.__new__(cls)
|
||||||
cls.list_store = Gio.ListStore.new(JoinValue)
|
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
|
return cls._instance
|
||||||
|
|
||||||
def _rerender_join_list(
|
def rerender_join_list(
|
||||||
self, source: GKVStore, position: int, removed: int, added: int
|
self, source: GKVStore, position: int, removed: int, added: int
|
||||||
) -> None:
|
) -> None:
|
||||||
self.list_store.items_changed(
|
self.list_store.items_changed(
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ def get_context() -> http.client.ssl.SSLContext:
|
|||||||
# certfile="/home/kenji/.config/sunshine/credentials/cacert.pem",
|
# certfile="/home/kenji/.config/sunshine/credentials/cacert.pem",
|
||||||
# keyfile="/home/kenji/.config/sunshine/credentials/cakey.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:
|
def pair(pin: str) -> str:
|
||||||
@@ -42,7 +42,9 @@ def pair(pin: str) -> str:
|
|||||||
def restart() -> None:
|
def restart() -> None:
|
||||||
# Define the connection
|
# Define the connection
|
||||||
conn = http.client.HTTPSConnection(
|
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")
|
user_and_pass = base64.b64encode(b"sunshine:sunshine").decode("ascii")
|
||||||
headers = {
|
headers = {
|
||||||
|
|||||||
@@ -19,16 +19,13 @@ class Config:
|
|||||||
cls._instance = super().__new__(cls)
|
cls._instance = super().__new__(cls)
|
||||||
cls._instance.config = configparser.ConfigParser()
|
cls._instance.config = configparser.ConfigParser()
|
||||||
config = config_location or cls._instance.default_sunshine_config_file()
|
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:
|
with open(config) as f:
|
||||||
config_string = f"[{PSEUDO_SECTION}]\n" + f.read()
|
config_string = f"[{PSEUDO_SECTION}]\n" + f.read()
|
||||||
print(config_string)
|
print(config_string)
|
||||||
cls._instance.config.read_string(config_string)
|
cls._instance.config.read_string(config_string)
|
||||||
return cls._instance
|
return cls._instance
|
||||||
|
|
||||||
def config_location(self) -> str:
|
|
||||||
return self._config_location
|
|
||||||
|
|
||||||
def default_sunshine_config_dir(self) -> str:
|
def default_sunshine_config_dir(self) -> str:
|
||||||
return os.path.join(os.path.expanduser("~"), ".config", "sunshine")
|
return os.path.join(os.path.expanduser("~"), ".config", "sunshine")
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ lint.select = [
|
|||||||
"RET",
|
"RET",
|
||||||
"RSE",
|
"RSE",
|
||||||
"RUF",
|
"RUF",
|
||||||
|
"SLF",
|
||||||
"T10",
|
"T10",
|
||||||
"TID",
|
"TID",
|
||||||
"U",
|
"U",
|
||||||
|
|||||||
Reference in New Issue
Block a user