Skip to content

Commit 35e9ffc

Browse files
authored
Merge pull request #254 from splunk/ruff_config
First crack at default config for `ruff` - Step 3.5 - ESCU 5.0
2 parents 4f92434 + 3530006 commit 35e9ffc

File tree

6 files changed

+134
-1
lines changed

6 files changed

+134
-1
lines changed

.github/workflows/ruff.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: lint & format
2+
on:
3+
pull_request:
4+
types: [opened, reopened, synchronize]
5+
6+
jobs:
7+
lint:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
- name: Install Python
12+
uses: actions/setup-python@v5
13+
with:
14+
python-version: "3.11"
15+
- name: Install ruff
16+
run: |
17+
python -m pip install --upgrade pip
18+
pip install ruff
19+
- name: Run lint
20+
run: ruff check --output-format=github contentctl/
21+
- name: Run Formatter
22+
run: ruff format --check contentctl/

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ poetry.lock
33
# usual mac files
44
.DS_Store
55
*/.DS_Store
6+
.ruff_cache
67

78
# custom
89
dist/*

.pre-commit-config.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v5.0.0 # Use the ref you want to point at
4+
hooks:
5+
- id: check-json
6+
- id: check-symlinks
7+
- id: check-yaml
8+
- id: detect-aws-credentials
9+
- id: detect-private-key
10+
- id: forbid-submodules
11+
- repo: https://github.com/astral-sh/ruff-pre-commit
12+
rev: v0.9.2
13+
hooks:
14+
- id: ruff
15+
args: [ --fix ]
16+
- id: ruff-format

.vscode/extensions.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"recommendations": [
3+
"charliermarsh.ruff"
4+
]
5+
}

.vscode/settings.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,15 @@
44
"python.testing.cwd": "${workspaceFolder}",
55
"python.languageServer": "Pylance",
66
"python.analysis.typeCheckingMode": "strict",
7-
"editor.defaultFormatter": "ms-python.black-formatter"
7+
"[python]": {
8+
"editor.formatOnSave": true,
9+
"editor.codeActionsOnSave": {
10+
"source.fixAll": "explicit",
11+
"source.organizeImports": "explicit"
12+
},
13+
"editor.defaultFormatter": "charliermarsh.ruff",
14+
},
15+
"ruff.nativeServer": "on"
816

917

1018
}

pyproject.toml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,87 @@ gitpython = "^3.1.43"
3232
setuptools = ">=69.5.1,<76.0.0"
3333
[tool.poetry.dev-dependencies]
3434

35+
[tool.poetry.group.dev.dependencies]
36+
ruff = "^0.9.2"
37+
3538
[build-system]
3639
requires = ["poetry-core>=1.0.0"]
3740
build-backend = "poetry.core.masonry.api"
41+
42+
[tool.ruff]
43+
# Exclude a variety of commonly ignored directories.
44+
exclude = [
45+
".bzr",
46+
".direnv",
47+
".eggs",
48+
".git",
49+
".git-rewrite",
50+
".hg",
51+
".ipynb_checkpoints",
52+
".mypy_cache",
53+
".nox",
54+
".pants.d",
55+
".pyenv",
56+
".pytest_cache",
57+
".pytype",
58+
".ruff_cache",
59+
".svn",
60+
".tox",
61+
".venv",
62+
".vscode",
63+
"__pypackages__",
64+
"_build",
65+
"buck-out",
66+
"build",
67+
"dist",
68+
"node_modules",
69+
"site-packages",
70+
"venv",
71+
]
72+
73+
# Same as Black.
74+
line-length = 88
75+
indent-width = 4
76+
77+
target-version = "py311"
78+
79+
[tool.ruff.lint]
80+
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
81+
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
82+
# McCabe complexity (`C901`) by default.
83+
select = ["E4", "E7", "E9", "F"]
84+
ignore = []
85+
86+
# Allow fix for all enabled rules (when `--fix`) is provided.
87+
fixable = ["ALL"]
88+
unfixable = []
89+
90+
# Allow unused variables when underscore-prefixed.
91+
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
92+
93+
[tool.ruff.format]
94+
# Like Black, use double quotes for strings.
95+
quote-style = "double"
96+
97+
# Like Black, indent with spaces, rather than tabs.
98+
indent-style = "space"
99+
100+
# Like Black, respect magic trailing commas.
101+
skip-magic-trailing-comma = false
102+
103+
# Like Black, automatically detect the appropriate line ending.
104+
line-ending = "auto"
105+
106+
# Enable auto-formatting of code examples in docstrings. Markdown,
107+
# reStructuredText code/literal blocks and doctests are all supported.
108+
#
109+
# This is currently disabled by default, but it is planned for this
110+
# to be opt-out in the future.
111+
docstring-code-format = false
112+
113+
# Set the line length limit used when formatting code snippets in
114+
# docstrings.
115+
#
116+
# This only has an effect when the `docstring-code-format` setting is
117+
# enabled.
118+
docstring-code-line-length = "dynamic"

0 commit comments

Comments
 (0)