diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 0000000..32e8e13 --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,18 @@ +name: Verify formatting + +on: + push: + branches: master + pull_request: + +jobs: + ruff: + runs-on: ubuntu-latest + name: Verify Python formatting + steps: + - uses: actions/checkout@v5 + + - uses: astral-sh/ruff-action@v3 + with: + version: "0.13.1" + args: "format --check" diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 32f1157..b77a0aa 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -1,44 +1,15 @@ ---- -# MegaLinter GitHub Action configuration file -# More info at https://megalinter.io -name: MegaLinter +name: Linting on: push: branches: "master" pull_request: jobs: - megalinter: - name: MegaLinter + ruff: runs-on: ubuntu-latest - permissions: - # Give the linter write permission to comment on PRs (if PR is not from fork) - issues: write - pull-requests: write + name: Lint Python steps: - # Git Checkout - - name: Checkout Code - uses: actions/checkout@v5 - with: - token: ${{ secrets.GITHUB_TOKEN }} - fetch-depth: 0 - # MegaLinter - - name: MegaLinter - id: ml - # You can override MegaLinter flavor used to have faster performances - # More info at https://megalinter.io/flavors/ - uses: oxsecurity/megalinter/flavors/python@v8 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # Validate whole codebase on pushes and only changes on pull requests - VALIDATE_ALL_CODEBASE: ${{ github.event_name == 'push'}} - - # Upload MegaLinter artifacts - - name: Archive production artifacts - if: success() || failure() - uses: actions/upload-artifact@v4 - with: - name: MegaLinter reports - path: | - megalinter-reports - mega-linter.log + - uses: actions/checkout@v5 + - uses: astral-sh/ruff-action@v3 + with: + version: "0.13.1" diff --git a/.mega-linter.yml b/.mega-linter.yml deleted file mode 100644 index 5562745..0000000 --- a/.mega-linter.yml +++ /dev/null @@ -1,16 +0,0 @@ -# All available variables are described in documentation -# https://megalinter.io/configuration/ - -LINTER_RULES_PATH: . - -ENABLE_LINTERS: - - PYTHON_BLACK - - PYTHON_ISORT - - PYTHON_RUFF - -# Make workflow fail even on non blocking errors -FORMATTERS_DISABLE_ERRORS: false - -PYTHON_BLACK_CONFIG_FILE: pyproject.toml -PYTHON_ISORT_CONFIG_FILE: pyproject.toml -PYTHON_RUFF_CONFIG_FILE: pyproject.toml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8e556ed..1fb6e49 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: trailing-whitespace - id: mixed-line-ending @@ -8,16 +8,12 @@ repos: exclude: &exclude_pattern '^changelog.d/' - id: debug-statements - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.7.2 + rev: v0.13.1 hooks: # Run the linter - id: ruff - name: "Ruff: critical" - args: [ - '--select=E9,F63,F7,F82', - '--output-format=full', - '--statistics' - ] + name: "Ruff linting" + args: [ --fix ] types: [file, python] # Run the formatter - id: ruff-format diff --git a/pyproject.toml b/pyproject.toml index 28400b2..9d15a84 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -77,33 +77,13 @@ exclude = ["tests*"] [tool.setuptools_scm] write_to = "src/netsnmpy/version.py" -[tool.black] -line-length = 88 -# Exclude files even when passed directly as argument (for MegaLinter) -force-exclude = ''' -( - /( - \.eggs # exclude a few common directories in the - | \.git # root of the project - | \.hg - | \.mypy_cache - | \.nox - | \.tox - | \.venv - | \.ve - | _build - | buck-out - | build - | dist - ) -) -''' - [tool.ruff] line-length = 88 target-version = "py39" -# Exclude files even when passed directly as argument (for MegaLinter) -force-exclude = true + +[tool.ruff.lint] +select = ["E4", "E7", "E9", "F", "I"] +fixable = ["I"] [tool.coverage.report] diff --git a/src/netsnmpy/.git-blame-ignore-revs b/src/netsnmpy/.git-blame-ignore-revs new file mode 100644 index 0000000..070a63c --- /dev/null +++ b/src/netsnmpy/.git-blame-ignore-revs @@ -0,0 +1,2 @@ +# Reformat files using ruff v0.13.1 @johannaengland 22/09/2025 +ae84ef897aecaa6cbcf63ff19e73889193fdf4c8 diff --git a/src/netsnmpy/netsnmp.py b/src/netsnmpy/netsnmp.py index 9bd79f4..67e9a59 100644 --- a/src/netsnmpy/netsnmp.py +++ b/src/netsnmpy/netsnmp.py @@ -193,7 +193,7 @@ def __str__(self): if enum_value: value = f"{self.enum_value}({self.value})" elif self.textual_convention == "DisplayString": - value = f'{self.value.decode("utf-8")!r}' + value = f"{self.value.decode('utf-8')!r}" else: value = self.value return f"{self.symbolic_name} = {value}"