Skip to content

Commit ee128f8

Browse files
authored
Change Main Linter to Ruff (#1301)
* Change main linter to ruff * Yaml format * Replace tools in CI container with ruff
1 parent 9abd5a1 commit ee128f8

File tree

4 files changed

+111
-21
lines changed

4 files changed

+111
-21
lines changed
+1-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
1-
bandit
2-
black
3-
flake8
4-
flynt
5-
isort
1+
ruff
62
tox

.github/workflows/mega-linter.yml

+2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ jobs:
4343
DEFAULT_BRANCH: ${{ github.event_name == 'pull_request' && github.base_ref || 'main' }}
4444
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4545
# ADD YOUR CUSTOM ENV VARIABLES HERE TO OVERRIDE VALUES OF .mega-linter.yml AT THE ROOT OF YOUR REPOSITORY
46+
PYTHON_RUFF_ARGUMENTS: '--config=''output-format="github"'''
47+
PYTHON_RUFF_FORMAT_ARGUMENTS: '--config=''output-format="github"'''
4648

4749
# Upload Mega-Linter artifacts
4850
- name: Archive production artifacts

.mega-linter.yml

+4-16
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,14 @@ FILTER_REGEX_EXCLUDE: "(.*/?packages/.*)" # Ignore packages directories
1313
ENABLE_LINTERS: # If you use ENABLE_LINTERS variable, all other linters will be disabled by default
1414
- MARKDOWN_MARKDOWN_LINK_CHECK
1515
- MARKDOWN_MARKDOWNLINT
16-
- PYTHON_BANDIT
17-
- PYTHON_BLACK
18-
- PYTHON_FLAKE8
19-
- PYTHON_ISORT
20-
- PYTHON_PYLINT
16+
- PYTHON_RUFF
17+
- PYTHON_RUFF_FORMAT
2118
- RST_RST_LINT
2219
- RST_RSTCHECK
2320
- RST_RSTFMT
2421
- YAML_PRETTIER
2522
- YAML_V8R
2623
- YAML_YAMLLINT
2724

28-
PYTHON_FLAKE8_CONFIG_FILE: setup.cfg
29-
PYTHON_BLACK_CONFIG_FILE: pyproject.toml
30-
PYTHON_PYLINT_CONFIG_FILE: pyproject.toml
31-
PYTHON_ISORT_CONFIG_FILE: pyproject.toml
32-
PYTHON_BANDIT_CONFIG_FILE: pyproject.toml
33-
PYTHON_BANDIT_FILTER_REGEX_EXCLUDE: "tests"
34-
PYTHON_BANDIT_PRE_COMMANDS:
35-
- command: "pip install bandit[toml]"
36-
cwd: "workspace"
37-
38-
PYTHON_PYLINT_ARGUMENTS: "--fail-under=0 --fail-on=E"
25+
PYTHON_RUFF_CONFIG_FILE: pyproject.toml
26+
PYTHON_RUFF_FORMAT_CONFIG_FILE: pyproject.toml

pyproject.toml

+104
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,107 @@
1+
[tool.ruff]
2+
output-format = "grouped"
3+
line-length = 120
4+
target-version = "py37"
5+
extend-exclude = [
6+
"newrelic/packages/",
7+
"setup.py",
8+
]
9+
namespace-packages = ["testing_support"]
10+
11+
[tool.ruff.format]
12+
skip-magic-trailing-comma = true
13+
14+
[tool.ruff.lint]
15+
isort.split-on-trailing-comma=false
16+
select = [
17+
# Enabled linters and rules
18+
"F", # Pyflakes
19+
"E", # pycodestyle
20+
"W", # pycodestyle
21+
"I", # isort
22+
"N", # pep8-naming
23+
"D", # pydocstyle
24+
"UP", # pyupgrade
25+
"YTT", # flake8-2020
26+
"ANN", # flake8-annotations
27+
"ASYNC", # flake8-async
28+
"S", # flake8-bandit
29+
"BLE", # flake8-blind-except
30+
"FBT", # flake8-boolean-trap
31+
"B", # flake8-bugbear
32+
"A", # flake8-builtins
33+
"COM", # flake8-commas
34+
"C4", # flake8-comprehensions
35+
"T10", # flake8-debugger
36+
"EM", # flake8-errmsg
37+
"FA", # flake8-future-annotations
38+
"ISC", # flake8-implicit-str-concat
39+
"ICN", # flake8-import-conventions
40+
"LOG", # flake8-logging
41+
"G", # flake8-logging-format
42+
"INP", # flake8-no-pep420
43+
"PYI", # flake8-pyi
44+
"PT", # flake8-pytest-style
45+
"Q", # flake8-quotes
46+
"RSE", # flake8-raise
47+
"RET", # flake8-return
48+
"SLF", # flake8-self
49+
"SLOT", # flake8-slots
50+
"SIM", # flake8-simplify
51+
"TID", # flake8-tidy-imports
52+
"INT", # flake8-gettext
53+
"ARG", # flake8-unused-arguments
54+
"PTH", # flake8-use-pathlib
55+
"PGH", # pygrep-hooks
56+
"PL", # Pylint
57+
"TRY", # tryceratops
58+
"FLY", # flynt
59+
"PERF", # Perflint
60+
"FURB", # refurb
61+
"RUF", # Ruff-specific rules
62+
]
63+
64+
# Disabled Linters
65+
# "C90", # mccabe
66+
# "CPY", # flake8-copyright
67+
# "DTZ", # flake8-datetimez
68+
# "DJ", # flake8-django
69+
# "EXE", # flake8-executable
70+
# "PIE", # flake8-pie
71+
# "T20", # flake8-print
72+
# "TC", # flake8-type-checking
73+
# "TD", # flake8-todos
74+
# "FIX", # flake8-fixme
75+
# "ERA", # eradicate
76+
# "PD", # pandas-vet
77+
# "NPY", # NumPy-specific rules
78+
# "FAST", # FastAPI
79+
# "AIR", # Airflow
80+
# "DOC", # pydoclint
81+
82+
ignore = [
83+
# Ruff recommended linter rules to disable when using formatter
84+
"W191", # tab-indentation
85+
"E111", # indentation-with-invalid-multiple
86+
"E114", # indentation-with-invalid-multiple-comment
87+
"E117", # over-indented
88+
"D206", # docstring-tab-indentation
89+
"D300", # triple-single-quotes
90+
"Q000", # bad-quotes-inline-string
91+
"Q001", # bad-quotes-multiline-string
92+
"Q002", # bad-quotes-docstring
93+
"Q003", # avoidable-escaped-quote
94+
"COM812", # missing-trailing-comma
95+
"COM819", # prohibited-trailing-comma
96+
# Additional disabled rules
97+
"D203", # incorrect-blank-line-before-class
98+
"D213", # multi-line-summary-second-line
99+
]
100+
101+
[tool.ruff.lint.per-file-ignores]
102+
"conftest.py" = ["F401"]
103+
104+
# Alternate linters and formatters
1105
[tool.black]
2106
line-length = 120
3107
include = '\.pyi?$'

0 commit comments

Comments
 (0)