Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: Move to ruff for CI #109

Open
wants to merge 28 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
128116b
ci: First ruff fixes
gmuloc Sep 23, 2024
cf56f9d
ci: Ruff fix number 2
gmuloc Sep 23, 2024
7de372a
ci: Start type checking
gmuloc Sep 23, 2024
6328c26
ci: Add pylint config to pyproject.toml
gmuloc Sep 23, 2024
0a31ada
WIP: tests
gmuloc Sep 23, 2024
87af8ed
WIP: more ruff fixing
gmuloc Sep 30, 2024
3feb943
WIP: All ruff
gmuloc Sep 30, 2024
a6e6fd3
WIP: More ruff, some pytest fixes
gmuloc Sep 30, 2024
25f943a
ci: Finish ruffing it
gmuloc Sep 30, 2024
eee7caf
ci: Update pre-commit while we are at it
gmuloc Oct 1, 2024
0813e6b
Doc: Update README
gmuloc Oct 1, 2024
d52842a
ci: Fix tox
gmuloc Oct 1, 2024
b3af0e0
ci: Fixes
gmuloc Oct 1, 2024
fbb7e57
Merge branch 'devel' into move-to-ruff
gmuloc Oct 2, 2024
0b3a2a0
Merge branch 'devel' into move-to-ruff
gmuloc Oct 7, 2024
c7982e9
Merge branch 'devel' into move-to-ruff
gmuloc Oct 15, 2024
a9100c3
Merge branch 'devel' into move-to-ruff
gmuloc Oct 21, 2024
c6d70d2
ci: Update ruff
gmuloc Oct 21, 2024
59e0424
Merge branch 'devel' into move-to-ruff
gmuloc Oct 23, 2024
e30bbae
Merge branch 'devel' into move-to-ruff
gmuloc Oct 28, 2024
4781001
Merge branch 'devel' into move-to-ruff
gmuloc Nov 28, 2024
6a3edee
Apply suggestions from code review
gmuloc Nov 28, 2024
12483bb
Bump: Ruff 0.8.0
gmuloc Nov 28, 2024
2202f9b
Merge branch 'devel' into move-to-ruff
gmuloc Dec 2, 2024
d8c02ea
ci: Update to ruff 0.8,2
gmuloc Dec 11, 2024
530e162
Merge branch 'devel' into move-to-ruff
gmuloc Jan 2, 2025
5302111
Bump: Ruff to 0.8.4
gmuloc Jan 2, 2025
83a347d
Merge branch 'devel' into move-to-ruff
gmuloc Jan 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pull-request-management.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
python: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python: ["3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Setup Python
Expand Down
44 changes: 21 additions & 23 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See https://pre-commit.com/hooks.html for more hooks
ci:
autoupdate_commit_msg: "CI: pre-commit autoupdate"

files: ^(j2lint|tests)/

repos:
Expand Down Expand Up @@ -42,49 +42,47 @@ repos:
- '{#||#}'
- --no-extra-eol

- repo: https://github.com/pycqa/flake8
rev: 7.1.1
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.4
hooks:
- id: flake8
name: Check for PEP8 error on Python files
args:
- --config=/dev/null
- --max-line-length=160
types: [python]
- id: ruff
name: Run Ruff linter
args: [ --fix ]
- id: ruff-format
name: Run Ruff formatter

- repo: https://github.com/pycqa/pylint
rev: v3.3.3
hooks:
- id: pylint # Use pylintrc file in repository
- id: pylint
name: Check for Linting error on Python files
description: This hook runs pylint.
types: [python]
args:
- -rn # Only display messages
- -sn # Don't display the score
- --rcfile=pyproject.toml # Link to config file
# Suppress duplicate code for modules header
- -d duplicate-code
additional_dependencies:
- jinja2
- rich
exclude: ^tests/

- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
name: Check for changes when running isort on all python files

- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black
name: Check for changes when running Black on all python files

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.14.0
hooks:
- id: mypy
args:
- --config-file=pyproject.toml
# additional_dependencies:
# Do not run on test
files: ^(j2lint)/

- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
name: Checks for common misspellings in text files.
entry: codespell
language: python
types: [text]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Build a Jinja2 linter that will provide the following capabilities:

### Requirements

Python version 3.8+
Minimym Python version: 3.9

### Install with pip

Expand Down
8 changes: 6 additions & 2 deletions j2lint/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# Copyright (c) 2021-2025 Arista Networks, Inc.
# Use of this source code is governed by the MIT license
# that can be found in the LICENSE file.
"""__init__.py - A command-line utility that checks for best practices in Jinja2.
"""
"""__init__.py - A command-line utility that checks for best practices in Jinja2."""

from rich.console import Console

NAME = "j2lint"
VERSION = "v1.1.0"
DESCRIPTION = __doc__

__author__ = "Arista Networks"
__license__ = "MIT"
__version__ = VERSION

CONSOLE = Console()
11 changes: 5 additions & 6 deletions j2lint/__main__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
#!/usr/bin/python
# Copyright (c) 2021-2025 Arista Networks, Inc.
# Use of this source code is governed by the MIT license
# that can be found in the LICENSE file.
"""__main__.py - A command-line utility that checks for best practices in Jinja2.
"""
"""__main__.py - A command-line utility that checks for best practices in Jinja2."""

import sys
import traceback

from j2lint import CONSOLE
from j2lint.cli import run

if __name__ == "__main__":
try:
sys.exit(run())
except Exception:
print(traceback.format_exc())
except Exception: # noqa: BLE001
CONSOLE.print_exception(show_locals=True)
raise SystemExit from BaseException
Loading