Skip to content

Commit

Permalink
pylint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian-B committed Jun 26, 2024
1 parent 1bd0a14 commit d170db6
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 12 deletions.
7 changes: 4 additions & 3 deletions spalloc_client/protocol_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ class ProtocolClient(object):
This minimal implementation is intended to serve both simple applications
and as an example implementation of the protocol for other applications.
This implementation simply implements the protocol, presenting an RPC-like
interface to the server. For a higher-level interface built on top of this
This implementation simply implements the protocol,
presenting a Remote procedure call-like interface to the server.
For a higher-level interface built on top of this
client, see :py:class:`spalloc.Job`.
Usage examples::
Expand Down Expand Up @@ -430,6 +431,6 @@ def where_is(self, timeout: Optional[int] = None,
keywords = frozenset(kwargs)
if keywords not in ProtocolClient._acceptable_kwargs_for_where_is:
raise SpallocServerException(
"Invalid arguments: {}".format(", ".join(keywords)))
f"Invalid arguments: {', '.join(keywords)}")
kwargs["timeout"] = timeout
return self.call("where_is", **kwargs)
1 change: 1 addition & 0 deletions spalloc_client/scripts/alloc.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
SpallocServerException)
from spalloc_client.term import Terminal, render_definitions

# pylint: disable=invalid-name
arguments = None
t = None
_input = input # This is so we can monkey patch input during testing
Expand Down
2 changes: 1 addition & 1 deletion spalloc_client/scripts/machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# pylint: disable=wrong-spelling-in-docstring
# pylint: disable=wrong-spelling-in-docstring,wrong-spelling-in-comment
""" Command-line administrative machine management interface.
When called with no arguments the ``spalloc-machine`` command lists all
Expand Down
3 changes: 2 additions & 1 deletion spalloc_client/scripts/ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# pylint: disable=wrong-spelling-in-docstring
""" An administrative command-line process listing utility.
By default, the ``spalloc-ps`` command lists all running and queued jobs. For
Expand Down Expand Up @@ -96,7 +97,7 @@ def render_job_list(t, jobs, args):

owner = job["owner"]
if "keepalivehost" in job and job["keepalivehost"] is not None:
owner += " (%s)" % job["keepalivehost"]
owner += f" ({job['keepalivehost']})"

table.append((
job["job_id"],
Expand Down
4 changes: 2 additions & 2 deletions spalloc_client/scripts/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ def __call__(self, argv=None):
self.body(client, args)
return 0
except (IOError, OSError, ProtocolError, ProtocolTimeoutError) as e:
sys.stderr.write("Error communicating with server: {}\n".format(e))
sys.stderr.write(f"Error communicating with server: {e}\n")
return 1
except SpallocServerException as srv_exn:
sys.stderr.write("Error from server: {}\n".format(srv_exn))
sys.stderr.write(f"Error from server: {srv_exn}\n")
return 1
except Terminate as t:
t.exit()
13 changes: 8 additions & 5 deletions spalloc_client/term.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
from enum import IntEnum
from functools import partial

# pylint: disable=wrong-spelling-in-docstring


class ANSIDisplayAttributes(IntEnum):
""" Code numbers of ANSI display attributes for use with `ESC[...m`\
Expand Down Expand Up @@ -149,8 +151,7 @@ def set_attrs(self, attrs=tuple()):
"""
if not attrs:
return ""
return self("\033[{}m".format(
";".join(str(attr) for attr in attrs)))
return self(f"\033[{''.join(str(attr) for attr in attrs)}m")

def wrap(self, string=None, pre="", post=""):
""" Wrap a string in the suppled pre and post strings or just print\
Expand Down Expand Up @@ -243,6 +244,8 @@ def render_table(table, column_sep=" "):
length = len(str(string))
right_align = True
string = f(string)
else:
raise TypeError(f"Unexpected type {column=}")

padding = " " * (column_widths[i] - length)
if right_align:
Expand Down Expand Up @@ -271,7 +274,7 @@ def render_definitions(definitions, separator=": "):
definitions : :py:class:`collections.OrderedDict`
The key/value set to display.
separator : str
The seperator inserted between keys and values.
The separator inserted between keys and values.
"""
# Special case since max would fail
if not definitions:
Expand Down Expand Up @@ -383,7 +386,7 @@ def render_boards(board_groups, dead_links=frozenset(),
Lists the groups of boards to display. Label is a 3-character string
labelling the boards in the group, edge_inner and edge_outer are the
characters to use to draw board edges as a tuple ("___", "\\", "/")
which are to be used for the inner and outer board edges repsectively.
which are to be used for the inner and outer board edges respectively.
Board groups are drawn sequentially with later board groups obscuring
earlier ones when their edges or boards overlap.
dead_links : set([(x, y, z, link), ...])
Expand Down Expand Up @@ -411,7 +414,7 @@ def render_boards(board_groups, dead_links=frozenset(),
all_boards = set()

for boards, label, edge_inner, edge_outer in board_groups:
# Convert to Cartesian coords
# Convert to Cartesian coordinates
boards = set(_board_to_cartesian(x, y, z) for x, y, z in boards)
all_boards.update(boards)

Expand Down

0 comments on commit d170db6

Please sign in to comment.