Skip to content

Commit

Permalink
Update pre-commit hooks, ruff rules
Browse files Browse the repository at this point in the history
  • Loading branch information
martinhoyer committed Oct 25, 2024
1 parent 64d7e45 commit 1274de4
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ debian/tmp/
*.pyc
rtslib-*
venv/
.venv/
.idea
*egg-info/
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/charliermarsh/ruff-pre-commit
rev: v0.6.4
rev: v0.7.1
hooks:
- id: ruff
args: [--fix]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: check-case-conflict
- id: check-ast
Expand Down
6 changes: 2 additions & 4 deletions configshell/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -1243,10 +1243,8 @@ def ui_command_bookmarks(self, action, bookmark=None):
if not self.shell.prefs['bookmarks']:
bookmarks += "No bookmarks yet.\n"
else:
for (bookmark, path) \
in self.shell.prefs['bookmarks'].items():
if len(bookmark) == 1:
bookmark += '\0'
for (_bookmark, path) in self.shell.prefs['bookmarks'].items():
bookmark = _bookmark if len(_bookmark) != 1 else _bookmark + '\0'
underline = ''.ljust(len(bookmark), '-')
bookmarks += f"{bookmark}\n{underline}\n{path}\n\n"
self.shell.con.epy_write(bookmarks)
Expand Down
18 changes: 7 additions & 11 deletions configshell/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,12 +401,11 @@ def _complete_token_pparam(self, text, path, command, pparams, kparams):
target = self._current_node.get_node(path)
cmd_params, free_pparams, free_kparams = \
target.get_command_signature(command)
current_parameters = {}
for index in range(len(pparams)):
if index < len(cmd_params):
current_parameters[cmd_params[index]] = pparams[index]
for key, value in kparams.items():
current_parameters[key] = value
current_parameters = {
cmd_params[index]: pparams[index]
for index in range(min(len(pparams), len(cmd_params)))
}
current_parameters.update(kparams)
self._completion_help_topic = command
completion_method = target.get_completion_method(command)
self.log.debug(f"Command {command} accepts parameters {cmd_params}.")
Expand Down Expand Up @@ -544,11 +543,8 @@ def _complete_token_kparam(self, text, path, command, pparams, kparams):
self.log.debug(f"Completing '{current_value}' for kparam {keyword}")

self._current_parameter = keyword
current_parameters = {}
for index in range(len(pparams)):
current_parameters[cmd_params[index]] = pparams[index]
for key, value in kparams.items():
current_parameters[key] = value
current_parameters = {cmd_params[index]: pparams[index] for index in range(len(pparams))}
current_parameters.update(dict(kparams.items()))
completion_method = target.get_completion_method(command)
if completion_method:
completions = completion_method(
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ ignore = [
"B904", # raise-without-from-inside-except
"PLR09", # Too many branches/statements/arguments
"S105", # Possible hardcoded password assigned
"S605", # TODO Starting a process with a shell
"S607", # TODO Starting a process with a partial executable path
"RET505", # Unnecessary `else` after `return` statement
"PLW2901", # TODO `for` loop variable overwritten by assignment target
"UP031", # TODO Use format specifiers instead of percent format
Expand Down

0 comments on commit 1274de4

Please sign in to comment.