Skip to content

Commit

Permalink
fix pylint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastian-swob committed Nov 12, 2024
1 parent 4f3fbad commit 1c7d1c9
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 13 deletions.
8 changes: 6 additions & 2 deletions dev-tools/dev_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,10 @@ def _maybe_create_diagrams(arguments):
diagrams_format = (
arguments.diagramsFormat if arguments.diagramsFormat else "pdf"
)
cmd = f"{_SCRIPTS_DIR / 'pyreverse'} -k -o {diagrams_format} -p pytrnsys_process -d test-results pytrnsys_process"
cmd = (
f"{_SCRIPTS_DIR / 'pyreverse'} -k -o {diagrams_format}"
" -p pytrnsys_process -d test-results pytrnsys_process"
)
_print_and_run(cmd.split())


Expand Down Expand Up @@ -236,7 +239,8 @@ def _run_unit_tests_with_pytest(arguments, test_results_dir_path):
cmd = [
_SCRIPTS_DIR / "pytest",
"-v",
"--benchmark-skip" "--cov=pytrnsys_process",
"--benchmark-skip",
"--cov=pytrnsys_process",
f"--cov-report=html:{test_results_dir_path / 'coverage-html'}",
f"--cov-report=lcov:{test_results_dir_path / 'coverage.lcov'}",
"--cov-report=term",
Expand Down
11 changes: 7 additions & 4 deletions pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ confidence=HIGH,
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use "--disable=all --enable=classes
# --disable=W".
#TODO discuss disabled checks # pylint: disable=fixme
disable=raw-checker-failed,
bad-inline-option,
locally-disabled,
Expand All @@ -430,10 +431,12 @@ disable=raw-checker-failed,
deprecated-pragma,
use-symbolic-message-instead,
use-implicit-booleaness-not-comparison-to-string,
use-implicit-booleaness-not-comparison-to-zero
missing-module-docstring
missing-class-docstring
missing-function-docstring
use-implicit-booleaness-not-comparison-to-zero,
missing-module-docstring,
missing-class-docstring,
missing-function-docstring,
too-few-public-methods,
arguments-differ,


# Enable the message, report, category or checker with the given id(s). You can
Expand Down
5 changes: 3 additions & 2 deletions pytrnsys_process/headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ def init_headers(self):
try:
headers = HeaderReader.read(sim_file)
self._index_headers(headers, sim_file.parents[1], sim_file)
except Exception as e:
except Exception as e: # pylint: disable=broad-exception-caught

print(f"Could not read {sim_file}: {e}")

def init_headers_multi_thread(self):
Expand All @@ -32,7 +33,7 @@ def process_sim_file(sim_file):
try:
headers = HeaderReader.read(sim_file)
self._index_headers(headers, sim_file.parents[1], sim_file)
except Exception as e:
except Exception as e: # pylint: disable=broad-exception-caught
print(f"Could not read {sim_file}: {e}")

with ThreadPoolExecutor(max_workers=10) as executor:
Expand Down
4 changes: 3 additions & 1 deletion pytrnsys_process/plotters.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class ChartBase:
LEGEND_FONT_SIZE = 8
TITLE_FONT_SIZE = 12

# TODO: discuss if we should we use a dic or a dataclass for config values
# pylint: disable=too-many-arguments
def __init__(
self, df, x_label=X_LABEL, y_label=Y_LABEL, title=TITLE, size=SIZE_A4
):
Expand Down Expand Up @@ -66,7 +68,7 @@ def plot(self, columns: list[str]) -> Tuple[_plt.Figure | None, _plt.Axes]:
self.configure()
return self.fig, self.ax

def plotWithoutPandas(
def plot_without_pandas(
self, columns: list[str]
) -> Tuple[_plt.Figure | None, _plt.Axes]:
"""The matplot date formatter does not work when using df.plot func.
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions tests/pytrnsys_process/test_plotters.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class TestPlotter:

# TODO figure out why not passing # pylint: disable=fixme
@pytest.mark.skip(reason="broken")
def testMplInstallation(self):
def test_mpl_installation(self):
"""Checks whether Inkscape is installed correctly."""
assert "pdf" in _mpltc.comparable_formats()
assert "svg" in _mpltc.comparable_formats()
Expand All @@ -46,7 +46,7 @@ def test_create_stacked_bar_chart_for_monthly(self):
]

monthly_bar_chart = MonthlyBarChart(df)
fig, ax = monthly_bar_chart.plot(columns)
fig, _ = monthly_bar_chart.plot(columns)
fig.savefig(actual_file, format="png")

assert (
Expand All @@ -64,7 +64,7 @@ def test_create_curve_plot_for_hourly(self):
columns = ["QSrc1TIn", "QSrc1TOut"]

curve_plot = HourlyCurvePlot(df)
fig, ax = curve_plot.plot(columns)
fig, _ = curve_plot.plot(columns)
fig.savefig(actual_fig)

assert (
Expand All @@ -89,7 +89,7 @@ def test_create_curve_plot_for_hourly(self):
# _plt.show()


# TODO fix, does not work as expected :/
# TODO fix, does not work as expected :/ # pylint: disable=fixme
def compare_plots(actual_buf, expected_file, tolerance=0.001):
with _tf.NamedTemporaryFile(suffix=".png", delete=False) as actual_file:
actual_file.write(actual_buf.read())
Expand Down

0 comments on commit 1c7d1c9

Please sign in to comment.