Skip to content
Snippets Groups Projects
Commit 4e8357a7 authored by Hock, Martin's avatar Hock, Martin
Browse files

Merge branch '79-upgrade-pylint-job' into 'dev'

Resolve "Upgrade pylint job"

See merge request !68
parents e5bff479 38b69d7c
No related branches found
No related tags found
2 merge requests!69Merge changes to main,!68Resolve "Upgrade pylint job"
Pipeline #913219 passed
......@@ -28,8 +28,22 @@ Pylint:
stage: linting
needs: []
script:
- pip install pylint
- find . -type f -name '*.py' | xargs pylint -rn --rcfile='plotid/.pylintrc' # Find all python files and check the code with pylint
- mkdir -p public/badges public/lint
- echo undefined > public/badges/$CI_JOB_NAME.score
- pip install pylint-gitlab
- pylint --rcfile='plotid/.pylintrc' --output-format=text $(find -type f -name "*.py" ! -path "**/env*/**") | tee /tmp/pylint.txt
- sed -n 's/^Your code has been rated at \([-0-9.]*\)\/.*/\1/p' /tmp/pylint.txt > public/badges/$CI_JOB_NAME.score
- pylint --rcfile='plotid/.pylintrc' --output-format=pylint_gitlab.GitlabCodeClimateReporter $(find -type f -name "*.py" ! -path "**/env*/**") > codeclimate.json
- pylint --rcfile='plotid/.pylintrc' --output-format=pylint_gitlab.GitlabPagesHtmlReporter $(find -type f -name "*.py" ! -path "**/env*/**") > public/lint/index.html
after_script:
- anybadge --overwrite --label $CI_JOB_NAME --value=$(cat public/badges/$CI_JOB_NAME.score) --file=public/badges/$CI_JOB_NAME.svg 4=red 6=orange 8=yellow 10=green
- anybadge --overwrite --label="code style" --value=black --file=public/badges/code_style.svg --color=black
artifacts:
paths:
- public
reports:
codequality: codeclimate.json
when: always
Autoformatting:
stage: linting
......
......@@ -10,5 +10,5 @@ research data, the plot is based on. Additionally, the script that created the
plot will also be copied to the directory.
"""
__version__ = "0.2.2-b3"
__version__ = "0.3.0"
__author__ = "Institut Fluidsystemtechnik within nfdi4ing at TU Darmstadt"
......@@ -27,8 +27,6 @@ class PlotOptions:
__init__
validate_input
Check if input is correct type.
validate_list
Check if all elements of a given list are of certain type.
Attributes
----------
......@@ -78,7 +76,6 @@ class PlotOptions:
position: tuple[float, float],
**kwargs: Any,
) -> None:
self.figs = figs
self.figure_ids = kwargs.get("figure_ids", [])
self.rotation = rotation
......
......@@ -40,7 +40,6 @@ class PublishOptions:
dst_path: str,
**kwargs: Any,
) -> None:
if not isinstance(figs_and_ids, PlotIDTransfer):
raise RuntimeError("figs_and_ids is not an instance of PlotIDTransfer.")
self.figure = figs_and_ids.figs
......
# -*- coding: utf-8 -*-
"""Tag your picture with an ID."""
import os
import warnings
from importlib.resources import files
from PIL import Image, ImageDraw, ImageFont
from plotid.create_id import create_id, create_qrcode
from plotid.plotoptions import PlotOptions, PlotIDTransfer
from plotid.plotoptions import PlotOptions, PlotIDTransfer, validate_list
def tagplot_image(plotid_object: PlotOptions) -> PlotIDTransfer:
......@@ -30,11 +29,7 @@ def tagplot_image(plotid_object: PlotOptions) -> PlotIDTransfer:
)
# Check if figs is a list of files
for img in plotid_object.figs:
if not isinstance(img, str):
raise TypeError("Name of the image is not a string.")
if not os.path.isfile(img):
raise TypeError(f"Image '{img}' does not exist.")
plotid_object.figs = validate_list(plotid_object.figs, is_file=True)
# Check if figs is a valid file is done by pillow internally
color = tuple(rgb_value * 255 for rgb_value in plotid_object.fontcolor)
......
......@@ -62,7 +62,6 @@ def tagplot_matplotlib(plotid_object: PlotOptions) -> PlotIDTransfer:
plt.figure(fig)
if plotid_object.id_on_plot:
plt.figtext(
x=plotid_object.position[0],
y=plotid_object.position[1],
......
......@@ -52,7 +52,8 @@ class TestPublish(unittest.TestCase):
os.makedirs(SRC_DIR, exist_ok=True)
os.makedirs(DST_PARENT_DIR, exist_ok=True)
for file in SRC_FILES:
open(file, "w", encoding="utf-8").close()
with open(file, "w", encoding="utf-8"):
pass
os.mkdir(DST_DIR)
with open(TEXT_FILE, "x", encoding="utf-8") as file:
......
......@@ -78,7 +78,7 @@ class TestTagplotImage(unittest.TestCase):
"""Test if Error is raised if the image file does not exist."""
options = PlotOptions("xyz", ROTATION, POSITION)
options.validate_input()
with self.assertRaises(TypeError):
with self.assertRaises(FileNotFoundError):
tagplot_image(options)
def test_image_plotoptions(self) -> None:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment