From 772acc0e68a2be07e1167527098bc9cecc450e55 Mon Sep 17 00:00:00 2001 From: Jorge Martinez Date: Tue, 12 Sep 2023 09:35:44 +0200 Subject: [PATCH 01/14] maint: update implementation --- .pre-commit-config.yaml | 18 +++--------------- pyproject.toml | 30 ++++++++++++++++++++++++++---- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ec407a8978..7b72703939 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,15 +5,10 @@ repos: hooks: - id: black -- repo: https://github.com/pycqa/isort - rev: 5.12.0 +- repo: https://github.com/charliermarsh/ruff-pre-commit + rev: v0.0.239 hooks: - - id: isort - -- repo: https://github.com/PyCQA/flake8 - rev: 5.0.4 - hooks: - - id: flake8 + - id: ruff - repo: https://github.com/codespell-project/codespell rev: v2.2.1 @@ -21,10 +16,3 @@ repos: - id: codespell additional_dependencies: - tomli - -- repo: https://github.com/pycqa/pydocstyle - rev: 6.1.1 - hooks: - - id: pydocstyle - additional_dependencies: [toml] - exclude: "tests/" diff --git a/pyproject.toml b/pyproject.toml index be68f828d2..d6a04158b0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -53,19 +53,41 @@ Documentation = "https://stk.docs.pyansys.com/" Source = "https://github.com/pyansys/pystk" Tracker = "https://github.com/pyansys/pystk/issues" -[tool.black] -line-length = 80 +[tool.ruff] +select = [ + "E", # pycodestyle, see https://github.com/charliermarsh/ruff#pycodestyle-e-w + "D", # pydocstyle, see https://github.com/charliermarsh/ruff#pydocstyle-d + "F", # pyflakes, see https://github.com/charliermarsh/ruff#pyflakes-f + "I" # isort, see +] +ignore = [ + "E501", # Line too long + "D204" # One blank line required after class docstring +] +line-length = 120 +exclude = [ + ".git", + ".tox", + ".venv", + "_build", + "build", + "dist", + "venv", +] -[tool.isort] +[tool.ruff.isort] profile = "black" force_sort_within_sections = true -line_length = 80 +line_length = 120 default_section = "THIRDPARTY" src_paths = ["examples", "doc", "src", "tests"] [tool.codespell] ignore-words = "doc/styles/Vocab/ANSYS/accept.txt" +[tool.ruff.mccabe] +max-complexity = 10 + [tool.coverage.run] relative_files = true From b877b7dd4f60a133ccaffbe29dbccff2e87e9875 Mon Sep 17 00:00:00 2001 From: Jorge Martinez Date: Wed, 1 Feb 2023 08:12:36 +0100 Subject: [PATCH 02/14] FIX: add missing docstrings in test suite --- pyproject.toml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index d6a04158b0..1c0fde8197 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -61,10 +61,9 @@ select = [ "I" # isort, see ] ignore = [ - "E501", # Line too long - "D204" # One blank line required after class docstring + "E501", # Line too long. Ignoring this so "black" manages line length. + "D204" # One blank line required after class docstring. ] -line-length = 120 exclude = [ ".git", ".tox", From e348bb05299055a31f484b2224a794aed614adbf Mon Sep 17 00:00:00 2001 From: Jorge Martinez Date: Thu, 2 Feb 2023 08:09:38 +0100 Subject: [PATCH 03/14] MAINT: configure ruff.isort --- pyproject.toml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 1c0fde8197..0a85b4ed6c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -75,11 +75,9 @@ exclude = [ ] [tool.ruff.isort] -profile = "black" -force_sort_within_sections = true -line_length = 120 -default_section = "THIRDPARTY" -src_paths = ["examples", "doc", "src", "tests"] +combine-as-imports = true +force-sort-within-sections = true +known-first-party = ["ansys"] [tool.codespell] ignore-words = "doc/styles/Vocab/ANSYS/accept.txt" From b63f862a5598960edbdc451e9058d2632b2a3d14 Mon Sep 17 00:00:00 2001 From: Jorge Martinez Date: Thu, 2 Feb 2023 08:21:44 +0100 Subject: [PATCH 04/14] MAINT: enable fixing option in ruff --- .pre-commit-config.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7b72703939..f406cbeb32 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,6 +9,7 @@ repos: rev: v0.0.239 hooks: - id: ruff + args: [--fix] - repo: https://github.com/codespell-project/codespell rev: v2.2.1 From ebcf85c38242e632a56e77f3f8698811dea0f404 Mon Sep 17 00:00:00 2001 From: Jorge Martinez Date: Thu, 2 Feb 2023 09:50:55 +0100 Subject: [PATCH 05/14] MAINT: remove .flake8 file --- .flake8 | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 .flake8 diff --git a/.flake8 b/.flake8 deleted file mode 100644 index 3270d96259..0000000000 --- a/.flake8 +++ /dev/null @@ -1,7 +0,0 @@ -[flake8] -exclude = __init__.py, doc/_build, .venv -select = W191, W291, W293, W391, E115, E117, E122, E124, E125, E225, E231, E301, E303, E501, F401, F403 -count = True -max-complexity = 10 -max-line-length = 80 -statistics = True From 8277543793ddf2c9153f7a371daa7bd8126901f7 Mon Sep 17 00:00:00 2001 From: Jorge Martinez Date: Thu, 2 Feb 2023 10:13:22 +0100 Subject: [PATCH 06/14] MAINT: ignore blank lines before and after class docstrings --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 0a85b4ed6c..146b048049 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -62,6 +62,7 @@ select = [ ] ignore = [ "E501", # Line too long. Ignoring this so "black" manages line length. + "D203", # One blank line required before class docstring. "D204" # One blank line required after class docstring. ] exclude = [ From 33ea32e58bda7a40d7bef95e645ea6873b3f036c Mon Sep 17 00:00:00 2001 From: Jorge Martinez Date: Tue, 12 Sep 2023 09:40:21 +0200 Subject: [PATCH 07/14] maint: update ruff version in pre-commit --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f406cbeb32..d18beaa4e3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,7 +6,7 @@ repos: - id: black - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.0.239 + rev: v0.0.287 hooks: - id: ruff args: [--fix] From a112d44905f48780c11e7511d067c63d5f1db990 Mon Sep 17 00:00:00 2001 From: Jorge Martinez Date: Tue, 12 Sep 2023 09:55:11 +0200 Subject: [PATCH 08/14] maint: add black configuration --- .pre-commit-config.yaml | 6 +++--- pyproject.toml | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d18beaa4e3..85c0476588 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,18 +1,18 @@ repos: - repo: https://github.com/psf/black - rev: 22.8.0 + rev: 23.9.1 hooks: - id: black - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.0.287 + rev: v0.0.288 hooks: - id: ruff args: [--fix] - repo: https://github.com/codespell-project/codespell - rev: v2.2.1 + rev: v2.2.5 hooks: - id: codespell additional_dependencies: diff --git a/pyproject.toml b/pyproject.toml index 146b048049..8561bde196 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -53,7 +53,11 @@ Documentation = "https://stk.docs.pyansys.com/" Source = "https://github.com/pyansys/pystk" Tracker = "https://github.com/pyansys/pystk/issues" +[tool.black] +line-length = 120 + [tool.ruff] +line-length = 120 select = [ "E", # pycodestyle, see https://github.com/charliermarsh/ruff#pycodestyle-e-w "D", # pydocstyle, see https://github.com/charliermarsh/ruff#pydocstyle-d From ecf40a02a4176ae3a4bf6870bd95e88c7193c7cd Mon Sep 17 00:00:00 2001 From: Jorge Martinez Date: Tue, 12 Sep 2023 09:58:25 +0200 Subject: [PATCH 09/14] feat: enable naming style checks --- pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 8561bde196..3f32727811 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -62,7 +62,8 @@ select = [ "E", # pycodestyle, see https://github.com/charliermarsh/ruff#pycodestyle-e-w "D", # pydocstyle, see https://github.com/charliermarsh/ruff#pydocstyle-d "F", # pyflakes, see https://github.com/charliermarsh/ruff#pyflakes-f - "I" # isort, see + "I", # isort, see https://beta.ruff.rs/docs/rules/#isort-i + "N", # pep8-naming, see https://beta.ruff.rs/docs/rules/#pep8-naming-n ] ignore = [ "E501", # Line too long. Ignoring this so "black" manages line length. From aab462d1bc4b2cff817ebadacb48ee4906ec8324 Mon Sep 17 00:00:00 2001 From: Jorge Martinez Date: Tue, 12 Sep 2023 10:18:22 +0200 Subject: [PATCH 10/14] feat: extend default ignores --- pyproject.toml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 3f32727811..d9d996811e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -70,14 +70,8 @@ ignore = [ "D203", # One blank line required before class docstring. "D204" # One blank line required after class docstring. ] -exclude = [ - ".git", - ".tox", - ".venv", - "_build", - "build", - "dist", - "venv", +extend-exclude = [ + "src/ansys/stk/core/internal/*.py" ] [tool.ruff.isort] From 26fdd372f04631e87cb8f1e36426f6b1dda411e2 Mon Sep 17 00:00:00 2001 From: Jorge Martinez Date: Tue, 12 Sep 2023 10:59:56 +0200 Subject: [PATCH 11/14] feat: use pathlib in favor of os module --- pyproject.toml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index d9d996811e..c810bc5a73 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -59,11 +59,12 @@ line-length = 120 [tool.ruff] line-length = 120 select = [ - "E", # pycodestyle, see https://github.com/charliermarsh/ruff#pycodestyle-e-w - "D", # pydocstyle, see https://github.com/charliermarsh/ruff#pydocstyle-d - "F", # pyflakes, see https://github.com/charliermarsh/ruff#pyflakes-f - "I", # isort, see https://beta.ruff.rs/docs/rules/#isort-i - "N", # pep8-naming, see https://beta.ruff.rs/docs/rules/#pep8-naming-n + "E", # pycodestyle, see https://beta.ruff.rs/docs/rules/#pycodestyle-e-w + "D", # pydocstyle, see https://beta.ruff.rs/docs/rules/#pydocstyle-d + "F", # pyflakes, see https://beta.ruff.rs/docs/rules/#pyflakes-f + "I", # isort, see https://beta.ruff.rs/docs/rules/#isort-i + "N", # pep8-naming, see https://beta.ruff.rs/docs/rules/#pep8-naming-n + "PTH", # flake8-use-pathlib, https://beta.ruff.rs/docs/rules/#flake8-use-pathlib-pth ] ignore = [ "E501", # Line too long. Ignoring this so "black" manages line length. From 7346344427ad2192001863c0c481e915f7d68c0a Mon Sep 17 00:00:00 2001 From: Jorge Martinez Date: Tue, 12 Sep 2023 11:04:01 +0200 Subject: [PATCH 12/14] feat: ignore code style in tests/ --- pyproject.toml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c810bc5a73..b01837ed8c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,6 +55,7 @@ Tracker = "https://github.com/pyansys/pystk/issues" [tool.black] line-length = 120 +extend-exclude = ["tests"] [tool.ruff] line-length = 120 @@ -72,7 +73,8 @@ ignore = [ "D204" # One blank line required after class docstring. ] extend-exclude = [ - "src/ansys/stk/core/internal/*.py" + "src/ansys/stk/core/internal/*.py", + "tests/**/*.py", ] [tool.ruff.isort] From fd81f8d0703c1ea0a2c712f8caf2f8bba10881ed Mon Sep 17 00:00:00 2001 From: Jorge Martinez Date: Wed, 25 Oct 2023 09:26:36 +0200 Subject: [PATCH 13/14] maint: pre-commit autoupdate --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 85c0476588..2786498b30 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,18 +1,18 @@ repos: - repo: https://github.com/psf/black - rev: 23.9.1 + rev: 23.10.1 hooks: - id: black - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.0.288 + rev: v0.1.2 hooks: - id: ruff args: [--fix] - repo: https://github.com/codespell-project/codespell - rev: v2.2.5 + rev: v2.2.6 hooks: - id: codespell additional_dependencies: From b233335c086881ffb94cedd17bf9b071fae83a8d Mon Sep 17 00:00:00 2001 From: Jorge Martinez Date: Wed, 25 Oct 2023 09:28:46 +0200 Subject: [PATCH 14/14] maint: switch from black to ruff.formatter --- .pre-commit-config.yaml | 5 ----- pyproject.toml | 10 +++++----- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2786498b30..f14c6bb3a1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,10 +1,5 @@ repos: -- repo: https://github.com/psf/black - rev: 23.10.1 - hooks: - - id: black - - repo: https://github.com/charliermarsh/ruff-pre-commit rev: v0.1.2 hooks: diff --git a/pyproject.toml b/pyproject.toml index b01837ed8c..ac7693f12e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -53,10 +53,6 @@ Documentation = "https://stk.docs.pyansys.com/" Source = "https://github.com/pyansys/pystk" Tracker = "https://github.com/pyansys/pystk/issues" -[tool.black] -line-length = 120 -extend-exclude = ["tests"] - [tool.ruff] line-length = 120 select = [ @@ -68,7 +64,7 @@ select = [ "PTH", # flake8-use-pathlib, https://beta.ruff.rs/docs/rules/#flake8-use-pathlib-pth ] ignore = [ - "E501", # Line too long. Ignoring this so "black" manages line length. + "E501", # Line too long. Ignoring this so "ruff.formatter" manages line length. "D203", # One blank line required before class docstring. "D204" # One blank line required after class docstring. ] @@ -77,6 +73,10 @@ extend-exclude = [ "tests/**/*.py", ] +[tool.ruff.format] +quote-style = "single" +indent-style = "tab" + [tool.ruff.isort] combine-as-imports = true force-sort-within-sections = true