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 20 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 19 commits
Commits
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.7.0
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.1
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.12.1
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-2024 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-2024 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