Skip to content

Commit e485ee5

Browse files
committed
pylint: deal with too-many-positional-arguments
Convert to keyword-only arguments where it makes sense and disable warning in other places.
1 parent 7d66382 commit e485ee5

5 files changed

+28
-20
lines changed

qrexec/policy/parser.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,7 @@ class AskResolution(AbstractResolution):
723723
def __init__(self,
724724
rule: "Rule",
725725
request: "Request",
726+
*,
726727
# targets for the user to choose from
727728
targets_for_ask: Sequence[str],
728729
# default target, or None
@@ -913,7 +914,7 @@ def allow_no_autostart(target: str, system_info: FullSystemInfo) -> bool:
913914

914915
class Deny(ActionType):
915916
# pylint: disable=missing-docstring
916-
def __init__(self, rule: "Rule", notify: Optional[bool]=None):
917+
def __init__(self, rule: "Rule", *, notify: Optional[bool]=None):
917918
super().__init__(rule)
918919
self.notify = True if notify is None else notify
919920

@@ -950,6 +951,7 @@ class Allow(ActionType):
950951
def __init__(
951952
self,
952953
rule: "Rule",
954+
*,
953955
target: Optional[str]=None,
954956
user: Optional[str] = None,
955957
notify: bool = False,
@@ -1033,6 +1035,7 @@ class Ask(ActionType):
10331035
def __init__(
10341036
self,
10351037
rule: "Rule",
1038+
*,
10361039
target: Optional[str]=None,
10371040
default_target: Optional[str]=None,
10381041
user: Optional[str] = None,
@@ -1139,7 +1142,7 @@ class Rule:
11391142
:py:meth:`from_line_service()`.
11401143
"""
11411144

1142-
# pylint: disable=too-many-instance-attributes
1145+
# pylint: disable=too-many-instance-attributes,too-many-positional-arguments
11431146

11441147
action: Union[Allow, Deny, Ask]
11451148
def __init__(

qrexec/tests/qrexec_policy_daemon.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -89,21 +89,21 @@ async def qrexec_server(self, tmp_path, request):
8989
eval_server = await asyncio.start_unix_server(
9090
functools.partial(
9191
qrexec_policy_daemon.handle_qrexec_connection,
92-
log,
93-
mock_policy,
94-
False,
95-
b"policy.EvalSimple",
92+
log=log,
93+
policy_cache=mock_policy,
94+
check_gui=False,
95+
service_name=b"policy.EvalSimple",
9696
),
9797
path=str(tmp_path / "socket.Simple"),
9898
)
9999

100100
gui_server = await asyncio.start_unix_server(
101101
functools.partial(
102102
qrexec_policy_daemon.handle_qrexec_connection,
103-
log,
104-
mock_policy,
105-
True,
106-
b"policy.EvalGUI",
103+
log=log,
104+
policy_cache=mock_policy,
105+
check_gui=True,
106+
service_name=b"policy.EvalGUI",
107107
),
108108
path=str(tmp_path / "socket.GUI"),
109109
)

qrexec/tools/qrexec_policy_agent.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ def _connect_events(self):
435435
def __init__(
436436
self, entries_info, source, service, argument, targets_list, target=None
437437
):
438-
# pylint: disable=too-many-arguments
438+
# pylint: disable=too-many-arguments,too-many-positional-arguments
439439
sanitize_domain_name(source, assert_sanitized=True)
440440
sanitize_service_name(service, assert_sanitized=True)
441441

@@ -521,7 +521,7 @@ async def confirm_rpc(self):
521521
async def confirm_rpc(
522522
entries_info, source, service, argument, targets_list, target=None
523523
):
524-
# pylint: disable=too-many-arguments
524+
# pylint: disable=too-many-arguments,too-many-positional-arguments
525525
window = RPCConfirmationWindow(
526526
entries_info, source, service, argument, targets_list, target
527527
)
@@ -597,7 +597,7 @@ async def handle_notify(self, params):
597597
return ""
598598

599599
def notify(self, resolution, service, argument, source, target):
600-
# pylint: disable=too-many-arguments
600+
# pylint: disable=too-many-arguments,too-many-positional-arguments
601601
if argument == "+":
602602
rpc = service
603603
else:

qrexec/tools/qrexec_policy_daemon.py

+11-7
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ async def _extract_qrexec_parameters(reader):
164164
return invoked_service, service_argument, remote_domain
165165

166166

167-
# pylint: disable=too-many-return-statements,too-many-arguments
167+
# pylint: disable=too-many-return-statements,too-many-arguments,too-many-positional-arguments
168168
async def qrexec_policy_eval(
169169
log,
170170
policy_cache,
@@ -254,7 +254,7 @@ async def qrexec_policy_eval(
254254

255255
# pylint: disable=too-many-arguments
256256
async def handle_qrexec_connection(
257-
log, policy_cache, check_gui, service_name, reader, writer
257+
reader, writer, *, log, policy_cache, check_gui, service_name
258258
):
259259

260260
"""
@@ -311,17 +311,21 @@ async def start_serving(args=None):
311311
eval_server = await asyncio.start_unix_server(
312312
functools.partial(
313313
handle_qrexec_connection,
314-
log,
315-
policy_cache,
316-
False,
317-
b"policy.EvalSimple",
314+
log=log,
315+
policy_cache=policy_cache,
316+
check_gui=False,
317+
service_name=b"policy.EvalSimple",
318318
),
319319
path=args.eval_socket_path,
320320
)
321321

322322
gui_eval_server = await asyncio.start_unix_server(
323323
functools.partial(
324-
handle_qrexec_connection, log, policy_cache, True, b"policy.EvalGUI"
324+
handle_qrexec_connection,
325+
log=log,
326+
policy_cache=policy_cache,
327+
check_gui=True,
328+
service_name=b"policy.EvalGUI"
325329
),
326330
path=args.gui_socket_path,
327331
)

qrexec/tools/qrexec_policy_exec.py

+1
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ async def handle_request(
323323
intended_target: str,
324324
service_and_arg: str,
325325
log,
326+
*,
326327
just_evaluate: bool = False,
327328
assume_yes_for_ask: bool = False,
328329
allow_resolution_type: Optional[type]=None,

0 commit comments

Comments
 (0)