From b337e1a715c66c5a3ed9db80019502f8bbbddfe6 Mon Sep 17 00:00:00 2001 From: LeXofLeviafan Date: Tue, 14 Feb 2023 15:22:31 +0100 Subject: [PATCH] fixed linter warnings & moved linting to a separate CI job --- .circleci/config.yml | 25 ++++++++++++++++++++++--- bukuserver/views.py | 15 +++++---------- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 731af56c..966ff324 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -12,22 +12,40 @@ test-template: &test-template environment: CI_FORCE_TEST: 1 steps: - - run: + - run: &init command: | apt update && apt install -y --no-install-recommends git pip install --upgrade pip pip install --upgrade setuptools flake8 pylint - checkout - - run: + - run: &deps command: | pip install -e .[tests] pip install -r requirements.txt + - run: + command: + python3 -m pytest ./tests/test_*.py --cov buku -vv --durations=0 -c ./tests/pytest.ini + +lint-template: &lint-template + working_directory: ~/Buku + environment: + CI_FORCE_TEST: 1 + steps: + - run: *init + - checkout + - run: *deps + - run: + command: | python3 -m flake8 echo buku | xargs pylint --rcfile tests/.pylintrc find . -iname "*.py" ! -path "./api/*" | xargs pylint --rcfile tests/.pylintrc - python3 -m pytest ./tests/test_*.py --cov buku -vv --durations=0 -c ./tests/pytest.ini jobs: + lint: + docker: + - image: python:3.7-slim + <<: *lint-template + py37: docker: - image: python:3.7-slim @@ -102,6 +120,7 @@ workflows: test: jobs: &all-tests + - lint - py37 - py38 - py39 diff --git a/bukuserver/views.py b/bukuserver/views.py index d6f38c7f..9e357860 100644 --- a/bukuserver/views.py +++ b/bukuserver/views.py @@ -215,8 +215,7 @@ def create_model(self, form): ) LOG.exception(msg) return False - else: - self.after_model_change(form, model, True) + self.after_model_change(form, model, True) return model def delete_model(self, model): @@ -232,8 +231,7 @@ def delete_model(self, model): ) LOG.exception(msg) return False - else: - self.after_model_delete(model) + self.after_model_delete(model) return res def get_list(self, page, sort_field, sort_desc, _, filters, page_size=None): @@ -409,8 +407,7 @@ def update_model(self, form: forms.BookmarkForm, model: Namespace): ) LOG.exception(msg) return False - else: - self.after_model_change(form, model, False) + self.after_model_change(form, model, False) return res @@ -560,8 +557,7 @@ def delete_model(self, model): ) LOG.exception(msg) return False - else: - self.after_model_delete(model) + self.after_model_delete(model) return res def update_model(self, form, model): @@ -581,8 +577,7 @@ def update_model(self, form, model): ) LOG.exception(msg) return False - else: - self.after_model_change(form, model, False) + self.after_model_change(form, model, False) return res def create_model(self, form):