Skip to content

Commit e31aba4

Browse files
authored
Merge pull request #1611 from wyardley/wyardley/chore/ruff
chore: switch to ruff for code formatting
2 parents 36b30ac + ce0bc6d commit e31aba4

17 files changed

+2070
-1203
lines changed

.github/workflows/linting.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
runs-on: ubuntu-latest
99
strategy:
1010
matrix:
11-
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
11+
python-version: ['3.10', '3.11', '3.12', '3.13']
1212
name: Python ${{ matrix.python-version }}
1313

1414
steps:
@@ -26,10 +26,10 @@ jobs:
2626
run: pip install poetry
2727
- name: poetry install
2828
run: poetry install
29-
- name: check code style with black
30-
run: make black
31-
- name: flake8 tests
32-
run: make flake8
29+
- name: check code style with ruff
30+
run: make ruff-format-check
31+
- name: ruff check
32+
run: make ruff-check
3333
- name: bandit
3434
run: make bandit
3535
- name: mypy

.github/workflows/main.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
runs-on: ubuntu-latest
99
strategy:
1010
matrix:
11-
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
11+
python-version: ['3.10', '3.11', '3.12', '3.13']
1212
name: Python ${{ matrix.python-version }}
1313

1414
steps:

.github/workflows/windows.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
runs-on: windows-latest
99
strategy:
1010
matrix:
11-
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
11+
python-version: ['3.10', '3.11', '3.12', '3.13']
1212
name: Python ${{ matrix.python-version }} (Windows)
1313

1414
steps:

.pre-commit-config.yaml

+35-33
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,36 @@
1+
---
12
repos:
2-
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v2.3.0
4-
hooks:
5-
- id: check-yaml
6-
- id: end-of-file-fixer
7-
exclude: |
8-
(?x)^(
9-
simplemonitor/html/dist/.*bundle.js
10-
)$
11-
- id: trailing-whitespace
12-
exclude: |
13-
(?x)^(
14-
tests/test_alerter.py|
15-
tests/html/.*
16-
)$
17-
- id: flake8
18-
- repo: https://github.com/psf/black
19-
rev: 25.1.0
20-
hooks:
21-
- id: black
22-
- repo: https://github.com/asottile/seed-isort-config
23-
rev: v2.2.0
24-
hooks:
25-
- id: seed-isort-config
26-
- repo: https://github.com/pre-commit/mirrors-isort
27-
rev: v5.9.2 # pick the isort version you'd like to use from https://github.com/pre-commit/mirrors-isort/releases
28-
hooks:
29-
- id: isort
30-
- repo: https://github.com/pre-commit/mirrors-mypy
31-
rev: v0.910
32-
hooks:
33-
- id: mypy
34-
args: ["--install-types", "--non-interactive"]
3+
- repo: https://github.com/pre-commit/pre-commit-hooks
4+
rev: v5.0.0
5+
hooks:
6+
- id: check-yaml
7+
- id: end-of-file-fixer
8+
exclude: |
9+
(?x)^(
10+
simplemonitor/html/dist/.*bundle.js
11+
)$
12+
- id: trailing-whitespace
13+
exclude: |
14+
(?x)^(
15+
tests/test_alerter.py|
16+
tests/html/.*
17+
)$
18+
- repo: https://github.com/astral-sh/ruff-pre-commit
19+
rev: v0.9.9
20+
hooks:
21+
- id: ruff
22+
args: [--fix]
23+
- id: ruff-format
24+
- repo: https://github.com/asottile/seed-isort-config
25+
rev: v2.2.0
26+
hooks:
27+
- id: seed-isort-config
28+
- repo: https://github.com/pre-commit/mirrors-isort
29+
rev: v5.9.2
30+
hooks:
31+
- id: isort
32+
- repo: https://github.com/pre-commit/mirrors-mypy
33+
rev: v0.910
34+
hooks:
35+
- id: mypy
36+
args: ["--install-types", "--non-interactive"]

Makefile

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: flake8 dist twine twine-test integration-tests env-test network-test black mypy linting mypy-strict bandit bandit-strict
1+
.PHONY: dist twine twine-test integration-tests env-test network-test ruff-check ruff-format ruff-format-check mypy linting mypy-strict bandit bandit-strict
22

33
ifeq ($(OS),Windows_NT)
44
MOCKSPATH := tests\mocks;
@@ -9,9 +9,6 @@ INTEGRATION_CONFIG := tests/monitor.ini
99
endif
1010
PIPENV := $(shell which poetry)
1111

12-
flake8:
13-
poetry run ruff check monitor.py simplemonitor/
14-
1512
integration-tests:
1613
PATH="$(MOCKSPATH)$(PATH)" $(PIPENV) run coverage run monitor.py -1 -v -d -f $(INTEGRATION_CONFIG) -j 1
1714

@@ -39,8 +36,14 @@ twine-test:
3936
twine:
4037
poetry run python -m twine upload dist/*
4138

42-
black:
43-
poetry run black --check --diff *.py simplemonitor/
39+
ruff-check:
40+
poetry run ruff check monitor.py simplemonitor/
41+
42+
ruff-format:
43+
poetry run ruff format
44+
45+
ruff-format-check:
46+
poetry run ruff format --check --diff
4447

4548
mypy:
4649
poetry run mypy *.py simplemonitor/
@@ -54,7 +57,7 @@ bandit:
5457
bandit-strict:
5558
poetry run bandit -r -l *.py simplemonitor/
5659

57-
linting: black flake8 mypy bandit
60+
linting: ruff-format ruff-check mypy bandit
5861

5962
docker-build:
6063
docker build -f docker/monitor.Dockerfile .

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
![Tests (Windows)](https://github.com/jamesoff/simplemonitor/workflows/Tests%20(Windows)/badge.svg) ![Tests (Linux)](https://github.com/jamesoff/simplemonitor/workflows/Tests%20(Linux)/badge.svg) ![Linting](https://github.com/jamesoff/simplemonitor/workflows/Linting/badge.svg)
44

5-
[![codecov](https://codecov.io/gh/jamesoff/simplemonitor/branch/master/graph/badge.svg)](https://codecov.io/gh/jamesoff/simplemonitor) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
5+
[![codecov](https://codecov.io/gh/jamesoff/simplemonitor/branch/master/graph/badge.svg)](https://codecov.io/gh/jamesoff/simplemonitor) [![Code style: ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v0.json)](https://github.com/astral-sh/ruff)
66

77
SimpleMonitor is a Python script which monitors hosts and network connectivity. It is designed to be quick and easy to set up and lacks complex features that can make things like Nagios, OpenNMS and Zenoss overkill for a small business or home network. Remote monitor instances can send their results back to a central location.
88

0 commit comments

Comments
 (0)