Skip to content

Commit 665cf7d

Browse files
Merge pull request #12 from Uninett/workflows/ruff
Use ruff instead of MegaLinter for linting/formatting
2 parents 72ce8cd + e3120e5 commit 665cf7d

File tree

7 files changed

+36
-85
lines changed

7 files changed

+36
-85
lines changed

.github/workflows/format.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Verify formatting
2+
3+
on:
4+
push:
5+
branches: master
6+
pull_request:
7+
8+
jobs:
9+
ruff:
10+
runs-on: ubuntu-latest
11+
name: Verify Python formatting
12+
steps:
13+
- uses: actions/checkout@v5
14+
15+
- uses: astral-sh/ruff-action@v3
16+
with:
17+
version: "0.13.1"
18+
args: "format --check"

.github/workflows/linter.yml

Lines changed: 7 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,15 @@
1-
---
2-
# MegaLinter GitHub Action configuration file
3-
# More info at https://megalinter.io
4-
name: MegaLinter
1+
name: Linting
52
on:
63
push:
74
branches: "master"
85
pull_request:
96

107
jobs:
11-
megalinter:
12-
name: MegaLinter
8+
ruff:
139
runs-on: ubuntu-latest
14-
permissions:
15-
# Give the linter write permission to comment on PRs (if PR is not from fork)
16-
issues: write
17-
pull-requests: write
10+
name: Lint Python
1811
steps:
19-
# Git Checkout
20-
- name: Checkout Code
21-
uses: actions/checkout@v5
22-
with:
23-
token: ${{ secrets.GITHUB_TOKEN }}
24-
fetch-depth: 0
25-
# MegaLinter
26-
- name: MegaLinter
27-
id: ml
28-
# You can override MegaLinter flavor used to have faster performances
29-
# More info at https://megalinter.io/flavors/
30-
uses: oxsecurity/megalinter/flavors/python@v8
31-
env:
32-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33-
# Validate whole codebase on pushes and only changes on pull requests
34-
VALIDATE_ALL_CODEBASE: ${{ github.event_name == 'push'}}
35-
36-
# Upload MegaLinter artifacts
37-
- name: Archive production artifacts
38-
if: success() || failure()
39-
uses: actions/upload-artifact@v4
40-
with:
41-
name: MegaLinter reports
42-
path: |
43-
megalinter-reports
44-
mega-linter.log
12+
- uses: actions/checkout@v5
13+
- uses: astral-sh/ruff-action@v3
14+
with:
15+
version: "0.13.1"

.mega-linter.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,19 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.6.0
3+
rev: v5.0.0
44
hooks:
55
- id: trailing-whitespace
66
- id: mixed-line-ending
77
- id: end-of-file-fixer
88
exclude: &exclude_pattern '^changelog.d/'
99
- id: debug-statements
1010
- repo: https://github.com/astral-sh/ruff-pre-commit
11-
rev: v0.7.2
11+
rev: v0.13.1
1212
hooks:
1313
# Run the linter
1414
- id: ruff
15-
name: "Ruff: critical"
16-
args: [
17-
'--select=E9,F63,F7,F82',
18-
'--output-format=full',
19-
'--statistics'
20-
]
15+
name: "Ruff linting"
16+
args: [ --fix ]
2117
types: [file, python]
2218
# Run the formatter
2319
- id: ruff-format

pyproject.toml

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -77,33 +77,13 @@ exclude = ["tests*"]
7777
[tool.setuptools_scm]
7878
write_to = "src/netsnmpy/version.py"
7979

80-
[tool.black]
81-
line-length = 88
82-
# Exclude files even when passed directly as argument (for MegaLinter)
83-
force-exclude = '''
84-
(
85-
/(
86-
\.eggs # exclude a few common directories in the
87-
| \.git # root of the project
88-
| \.hg
89-
| \.mypy_cache
90-
| \.nox
91-
| \.tox
92-
| \.venv
93-
| \.ve
94-
| _build
95-
| buck-out
96-
| build
97-
| dist
98-
)
99-
)
100-
'''
101-
10280
[tool.ruff]
10381
line-length = 88
10482
target-version = "py39"
105-
# Exclude files even when passed directly as argument (for MegaLinter)
106-
force-exclude = true
83+
84+
[tool.ruff.lint]
85+
select = ["E4", "E7", "E9", "F", "I"]
86+
fixable = ["I"]
10787

10888

10989
[tool.coverage.report]
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Reformat files using ruff v0.13.1 @johannaengland 22/09/2025
2+
ae84ef897aecaa6cbcf63ff19e73889193fdf4c8

src/netsnmpy/netsnmp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ def __str__(self):
193193
if enum_value:
194194
value = f"{self.enum_value}({self.value})"
195195
elif self.textual_convention == "DisplayString":
196-
value = f'{self.value.decode("utf-8")!r}'
196+
value = f"{self.value.decode('utf-8')!r}"
197197
else:
198198
value = self.value
199199
return f"{self.symbolic_name} = {value}"

0 commit comments

Comments
 (0)