-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pre-commit config for linting and formatting (#77)
* Add pre-commit config * Add pre-commit section to README * Use single line imports, add `from __future__ import annotations`
- Loading branch information
Showing
28 changed files
with
845 additions
and
264 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,4 +34,3 @@ jobs: | |
run: pip install hatch | ||
- name: Run tests | ||
run: hatch run test -vv | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# See https://pre-commit.com for more information | ||
# See https://pre-commit.com/hooks.html for more hooks | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v3.2.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
- id: end-of-file-fixer | ||
- id: check-yaml | ||
- id: check-added-large-files | ||
- repo: https://github.com/abravalheri/validate-pyproject | ||
rev: v0.15 | ||
hooks: | ||
- id: validate-pyproject | ||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
# Ruff version. | ||
rev: v0.3.3 | ||
hooks: | ||
# Run the linter. | ||
- id: ruff | ||
args: [ --fix ] | ||
# Run the formatter. | ||
- id: ruff-format |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ dynamic = ["version"] | |
description = "Zabbix auto config - ZAC" | ||
readme = "README.md" | ||
requires-python = ">=3.8" | ||
license = "MIT" | ||
license.file = "LICENSE" | ||
keywords = [] | ||
authors = [{ name = "Paal Braathen", email = "[email protected]" }] | ||
maintainers = [{ name = "Peder Hovdan Andresen", email = "[email protected]" }] | ||
|
@@ -57,3 +57,14 @@ exclude = ["/.github", "/tests", "/path"] | |
|
||
[tool.hatch.build.targets.wheel] | ||
packages = ["zabbix_auto_config"] | ||
|
||
[tool.ruff.lint] | ||
extend-select = [ | ||
"I", # isort | ||
] | ||
|
||
[tool.ruff.lint.isort] | ||
# Force one line per import to simplify diffing and merging | ||
force-single-line = true | ||
# Add annotations import to every file | ||
required-imports = ["from __future__ import annotations"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
from __future__ import annotations | ||
|
||
import multiprocessing | ||
import os | ||
from pathlib import Path | ||
from typing import Iterable, Type | ||
from unittest.mock import MagicMock | ||
import pytest | ||
from typing import Iterable | ||
from typing import Type | ||
from unittest import mock | ||
from unittest.mock import MagicMock | ||
|
||
import pytest | ||
import tomli | ||
|
||
from zabbix_auto_config import models | ||
|
@@ -110,6 +113,7 @@ def sample_config(): | |
def config(sample_config: str) -> Iterable[models.Settings]: | ||
yield models.Settings(**tomli.loads(sample_config)) | ||
|
||
|
||
@pytest.fixture | ||
def hostgroup_map_file(tmp_path: Path) -> Iterable[Path]: | ||
contents = """ | ||
|
@@ -118,8 +122,8 @@ def hostgroup_map_file(tmp_path: Path) -> Iterable[Path]: | |
# Example: <siteadm>:<host/user groupname> | ||
# | ||
#**************************************************************************************** | ||
# ATT: First letter will be capitilazed, leading and trailing spaces will be removed and | ||
# spaces within the hostgroupname will be replaced with "-" by the script automatically | ||
# ATT: First letter will be capitilazed, leading and trailing spaces will be removed and | ||
# spaces within the hostgroupname will be replaced with "-" by the script automatically | ||
#**************************************************************************************** | ||
# | ||
[email protected]:Hostgroup-user1-primary | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
from __future__ import annotations | ||
|
||
from zabbix_auto_config.models import Host | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.