Skip to content

Commit

Permalink
Various fixes to get pep8 and py3 to pass
Browse files Browse the repository at this point in the history
  • Loading branch information
ajkavanagh committed Nov 23, 2023
1 parent a819f2c commit f561bcc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
22 changes: 10 additions & 12 deletions charmhub_lp_tools/revisions.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import pathlib
import textwrap
from typing import (
Any,
Dict,
List,
Set,
Expand Down Expand Up @@ -179,15 +178,15 @@ def format_as_rst(
channel: CharmChannel,
results: Dict[str, Dict[str, List[int]]],
indent_level: int = 0) -> str:
"""Format the output as an ReST table (sphinx)
"""Format the output as an ReST table (sphinx).
This produces the table element with a group tab and then the included
rows.
:param results: the results to format into a table.
:returns: the formatted string
"""
rst_channel = format_channel_as_rst(results,indent_level=indent_level + 1)
rst_channel = format_channel_as_rst(results, indent_level=indent_level + 1)
if not rst_channel:
return ""
return "\n".join([
Expand All @@ -200,7 +199,7 @@ def format_as_rst(
def format_channel_as_rst(
results: Dict[str, Dict[str, List[int]]],
indent_level: int = 0) -> str:
"""Format the output as an ReST table (sphinx)
"""Format the output as an ReST table (sphinx).
This produces the table element; it'll need a header and group tabs created
by another section.
Expand Down Expand Up @@ -232,19 +231,19 @@ def format_channel_as_rst(
return "\n".join(output)


def format_rst_tabs(indent_level: int=0) -> str:
def format_rst_tabs(indent_level: int = 0) -> str:
"""Return the grouptab for an RST table.
:returns: a string of lines, indented, for the tabs.
"""
return textwrap.indent(
"\n".join([
f'.. tabs::',
'.. tabs::',
'',
]), ' ' * indent_level)


def format_rst_grouptab(header: str, indent_level: int=0) -> str:
def format_rst_grouptab(header: str, indent_level: int = 0) -> str:
"""Return the grouptab for an RST table.
:param header: the string to put in the header.
Expand All @@ -257,7 +256,7 @@ def format_rst_grouptab(header: str, indent_level: int=0) -> str:
]), ' ' * indent_level)


def format_rst_header(indent_level: int=0, num_cols=None) -> str:
def format_rst_header(indent_level: int = 0, num_cols=None) -> str:
"""Return the header for rst table.
:param indent_level: how var (*3 spaces) to indent this header.
Expand Down Expand Up @@ -290,7 +289,6 @@ def format_rst_row(columns: List[str],
:param indent_level: the level (*3 space) to indent the section.
:returns: a string of lines, indented, for the row.
"""

try:
lines: List[str] = ["* - {}".format(columns[0])]
except IndexError:
Expand All @@ -304,18 +302,18 @@ def format_rst_row(columns: List[str],
lines.append(f"{prefix}- {empty_column}")
prefix = " "
lines.append('')
lines = [l.rstrip() for l in lines]
lines = [line.rstrip() for line in lines]
return textwrap.indent("\n".join(lines), ' ' * indent_level)


def format_as_html(channel: CharmChannel,
results: Dict[str, Dict[str, List[int]]]) -> str:
results: Dict[str, Dict[str, List[int]]]) -> str:
"""Format the output as a HTML page.
:param results: the results to format into a table.
:returns: the formatted string
"""
raise NotImplemented("HTML reports aren't implemented yet.")
raise NotImplementedError("HTML reports aren't implemented yet.")


def print_revisions(
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ theblues
libcharmstore
launchpadlib
prettytable
humanize<4.0.0 # newer versions of humanize are incompatible with jinja2-humanize-extension
# humanize<4.0.0 # newer versions of humanize are incompatible with jinja2-humanize-extension
humanize
backports.zoneinfo; python_version < '3.9'
SecretStorage # LP: #1923727
macaroonbakery
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,4 @@ exclude = */charmhelpers
# D203 1 blank line required before class docstring (reason: pep257 default)
# D213 Multi-line docstring summary should start at the second line (reason: pep257 default)
# D215 Section underline is over-indented (reason: pep257 default)
ignore = D105, D107, D203, D213, D215
ignore = D105, D107, D203, D213, D215, D401

0 comments on commit f561bcc

Please sign in to comment.