From 89ef086ddc83943a9058ff8611d42f7a742f7d2e Mon Sep 17 00:00:00 2001 From: Johannes Nussbaum <39048939+jnussbaum@users.noreply.github.com> Date: Tue, 26 Sep 2023 15:39:23 +0200 Subject: [PATCH] chore: add isort check in pre-commit and GitHub CI (DEV-2707) (#529) --- .github/workflows/tests-on-push.yml | 3 +++ .pre-commit-config.yaml | 9 +++++++-- pyproject.toml | 6 ++++++ src/dsp_tools/models/connection.py | 2 +- src/dsp_tools/utils/excel2json/resources.py | 2 +- src/dsp_tools/utils/project_get.py | 2 +- 6 files changed, 19 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests-on-push.yml b/.github/workflows/tests-on-push.yml index 2396a2306..17c36ea29 100644 --- a/.github/workflows/tests-on-push.yml +++ b/.github/workflows/tests-on-push.yml @@ -62,6 +62,9 @@ jobs: - name: Linting with black run: poetry run black --check . + - name: Linting with isort + run: poetry run isort . --check --diff + - name: Linting with darglint run: poetry exec darglint diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1f0d44937..692a2d0c4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,7 +2,7 @@ repos: - repo: https://github.com/psf/black - rev: 23.3.0 + rev: 23.9.1 hooks: - id: black # It is recommended to specify the latest version of Python supported by your project here, @@ -38,7 +38,12 @@ repos: - id: text-unicode-replacement-char - repo: https://github.com/igorshubovych/markdownlint-cli - rev: v0.35.0 + rev: v0.37.0 hooks: - id: markdownlint args: [--config, .markdownlint.yml, --ignore, CHANGELOG.md] + + - repo: https://github.com/PyCQA/isort + rev: 5.11.5 + hooks: + - id: isort diff --git a/pyproject.toml b/pyproject.toml index 5e31980d0..873a78325 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -53,6 +53,7 @@ types-jsonschema = "^4.17.0.10" types-openpyxl = "^3.1.0.15" types-regex = "^2023.8.8.0" types-pyyaml = "^6.0.12.11" +isort = "^5.12.0" [tool.poetry.scripts] @@ -120,6 +121,11 @@ exclude = [ line-length = 120 +[tool.isort] +profile = "black" +line_length = 120 + + [tool.pylint.MASTER] ignore-paths = ["src/dsp_tools/models/resource.py"] # TODO: activate this suggestion-mode = true diff --git a/src/dsp_tools/models/connection.py b/src/dsp_tools/models/connection.py index 20fcc352f..256d89445 100644 --- a/src/dsp_tools/models/connection.py +++ b/src/dsp_tools/models/connection.py @@ -1,6 +1,6 @@ +import json from dataclasses import dataclass from datetime import datetime -import json from pathlib import Path from typing import Any, Optional, cast diff --git a/src/dsp_tools/utils/excel2json/resources.py b/src/dsp_tools/utils/excel2json/resources.py index 8cf41ea9e..2c9e7cca3 100644 --- a/src/dsp_tools/utils/excel2json/resources.py +++ b/src/dsp_tools/utils/excel2json/resources.py @@ -8,9 +8,9 @@ import pandas as pd import regex +import dsp_tools.utils.excel2json.utils as utl from dsp_tools.models.exceptions import UserError from dsp_tools.utils.shared import check_notna, prepare_dataframe -import dsp_tools.utils.excel2json.utils as utl languages = ["en", "de", "fr", "it", "rm"] diff --git a/src/dsp_tools/utils/project_get.py b/src/dsp_tools/utils/project_get.py index 7b94ea543..01c9ee8d0 100644 --- a/src/dsp_tools/utils/project_get.py +++ b/src/dsp_tools/utils/project_get.py @@ -1,6 +1,6 @@ import json -from typing import Any import warnings +from typing import Any import regex