From 2a5663d973d7f826ad4777bdd0fa7c6aa02f1dec Mon Sep 17 00:00:00 2001 From: ljstella Date: Thu, 22 Aug 2024 11:20:54 -0500 Subject: [PATCH 1/9] First crack at default config --- .vscode/settings.json | 10 +++++- pyproject.toml | 79 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 8a62413d..74d85aa8 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -4,7 +4,15 @@ "python.testing.cwd": "${workspaceFolder}", "python.languageServer": "Pylance", "python.analysis.typeCheckingMode": "strict", - "editor.defaultFormatter": "ms-python.black-formatter" + "[python]": { + "editor.formatOnSave": true, + "editor.codeActionsOnSave": { + "source.fixAll": "explicit", + "source.organizeImports": "explicit" + }, + "editor.defaultFormatter": "charliermarsh.ruff", + }, + "ruff.nativeServer": "on" } \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index e43c8bdf..6176e4d1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,3 +33,82 @@ setuptools = ">=69.5.1,<74.0.0" [build-system] requires = ["poetry-core>=1.0.0"] build-backend = "poetry.core.masonry.api" + +[tool.ruff] +# Exclude a variety of commonly ignored directories. +exclude = [ + ".bzr", + ".direnv", + ".eggs", + ".git", + ".git-rewrite", + ".hg", + ".ipynb_checkpoints", + ".mypy_cache", + ".nox", + ".pants.d", + ".pyenv", + ".pytest_cache", + ".pytype", + ".ruff_cache", + ".svn", + ".tox", + ".venv", + ".vscode", + "__pypackages__", + "_build", + "buck-out", + "build", + "dist", + "node_modules", + "site-packages", + "venv", +] + +# Same as Black. +line-length = 88 +indent-width = 4 + +# Assume Python 3.8 +target-version = "py38" + +[tool.ruff.lint] +# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default. +# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or +# McCabe complexity (`C901`) by default. +select = ["E4", "E7", "E9", "F"] +ignore = [] + +# Allow fix for all enabled rules (when `--fix`) is provided. +fixable = ["ALL"] +unfixable = [] + +# Allow unused variables when underscore-prefixed. +dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" + +[tool.ruff.format] +# Like Black, use double quotes for strings. +quote-style = "double" + +# Like Black, indent with spaces, rather than tabs. +indent-style = "space" + +# Like Black, respect magic trailing commas. +skip-magic-trailing-comma = false + +# Like Black, automatically detect the appropriate line ending. +line-ending = "auto" + +# Enable auto-formatting of code examples in docstrings. Markdown, +# reStructuredText code/literal blocks and doctests are all supported. +# +# This is currently disabled by default, but it is planned for this +# to be opt-out in the future. +docstring-code-format = false + +# Set the line length limit used when formatting code snippets in +# docstrings. +# +# This only has an effect when the `docstring-code-format` setting is +# enabled. +docstring-code-line-length = "dynamic" \ No newline at end of file From 3f7a585bea187ac06f5be04ef662eb4df1bb3fbe Mon Sep 17 00:00:00 2001 From: ljstella Date: Thu, 22 Aug 2024 12:41:55 -0500 Subject: [PATCH 2/9] Adding suggested extension config --- .vscode/extensions.json | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .vscode/extensions.json diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 00000000..8d1a435f --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "charliermarsh.ruff" + ] +} \ No newline at end of file From 0a88668f3812d616ddc1ee8b854d3d4bd77420f1 Mon Sep 17 00:00:00 2001 From: ljstella Date: Fri, 30 Aug 2024 14:56:36 -0500 Subject: [PATCH 3/9] Bumping target_version --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6176e4d1..618a9ca8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -70,7 +70,7 @@ line-length = 88 indent-width = 4 # Assume Python 3.8 -target-version = "py38" +target-version = "py311" [tool.ruff.lint] # Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default. @@ -111,4 +111,4 @@ docstring-code-format = false # # This only has an effect when the `docstring-code-format` setting is # enabled. -docstring-code-line-length = "dynamic" \ No newline at end of file +docstring-code-line-length = "dynamic" From 2568f7110aeab2554c5605c1c1168f4577874020 Mon Sep 17 00:00:00 2001 From: ljstella Date: Tue, 10 Sep 2024 14:12:04 -0500 Subject: [PATCH 4/9] Updated pyproject.toml --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 56df65ee..57e8d3bc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -69,7 +69,6 @@ exclude = [ line-length = 88 indent-width = 4 -# Assume Python 3.8 target-version = "py311" [tool.ruff.lint] From 0b4158b3f81e799a576e33943aeee34673282665 Mon Sep 17 00:00:00 2001 From: ljstella Date: Thu, 12 Sep 2024 09:18:47 -0500 Subject: [PATCH 5/9] Github CI --- .github/workflows/ruff.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/ruff.yml diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml new file mode 100644 index 00000000..6d84a781 --- /dev/null +++ b/.github/workflows/ruff.yml @@ -0,0 +1,23 @@ +name: lint & format +on: + push: + pull_request: + types: [opened, reopened, synchronize] + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + - name: Install ruff + run: | + python -m pip install --upgrade pip + pip install ruff + - name: Run lint + run: ruff check --output-format=github contentctl/ + - name: Run Formatter + run: ruff format --check contentctl/ \ No newline at end of file From f99655d4657a6649c043359c2df32e93bebd278a Mon Sep 17 00:00:00 2001 From: ljstella Date: Thu, 12 Sep 2024 09:24:45 -0500 Subject: [PATCH 6/9] Add precommit hook --- .pre-commit-config.yaml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..4c0bcb35 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,16 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 # Use the ref you want to point at + hooks: + - id: check-json + - id: check-symlinks + - id: check-yaml + - id: detect-aws-credentials + - id: detect-private-key + - id: forbid-submodules + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.6.4 + hooks: + - id: ruff + args: [ --fix ] + - id: ruff-format \ No newline at end of file From c1bdfbcebde244f58a0b0cd6285d6ffd4613d20a Mon Sep 17 00:00:00 2001 From: ljstella Date: Thu, 12 Sep 2024 09:25:10 -0500 Subject: [PATCH 7/9] Update gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 2e4fcc96..156005c0 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ poetry.lock # usual mac files .DS_Store */.DS_Store +.ruff_cache # custom dist/* From 7ed5e02a2872f00b4d5d8dd66976852dec3f46ce Mon Sep 17 00:00:00 2001 From: ljstella Date: Thu, 12 Sep 2024 09:46:09 -0500 Subject: [PATCH 8/9] Updating ruff workflow --- .github/workflows/ruff.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml index 6d84a781..4843361a 100644 --- a/.github/workflows/ruff.yml +++ b/.github/workflows/ruff.yml @@ -1,6 +1,5 @@ name: lint & format on: - push: pull_request: types: [opened, reopened, synchronize] From 9aa1607fff43ffc3c2487f153f33a1b16c50d217 Mon Sep 17 00:00:00 2001 From: ljstella Date: Thu, 12 Sep 2024 10:49:43 -0500 Subject: [PATCH 9/9] Adding ruff as dev dependency --- pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 3c9e4f6d..001d38a7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,6 +30,9 @@ gitpython = "^3.1.43" setuptools = ">=69.5.1,<75.0.0" [tool.poetry.dev-dependencies] +[tool.poetry.group.dev.dependencies] +ruff = "^0.6.4" + [build-system] requires = ["poetry-core>=1.0.0"] build-backend = "poetry.core.masonry.api"