Skip to content

Commit 75fd2e7

Browse files
committed
Added pre-commit.
1 parent cd8f864 commit 75fd2e7

File tree

5 files changed

+52
-2
lines changed

5 files changed

+52
-2
lines changed

.pre-commit-config.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.12.12
4+
hooks:
5+
- id: ruff
6+
args: [--fix]
7+
- id: ruff-format
8+
- repo: https://github.com/pre-commit/mirrors-mypy
9+
rev: v1.17.1
10+
hooks:
11+
- id: mypy
12+
args: [--ignore-missing-imports]
13+
- repo: local
14+
hooks:
15+
- id: pytest-coverage
16+
name: Tests with 80% coverage
17+
entry: python -m pytest --cov=eoapi_notifier --cov-fail-under=80 --tb=short
18+
language: system
19+
types: [python]
20+
pass_filenames: false
21+
always_run: true

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,26 @@ uv sync --extra test
1919
uv run pytest
2020
```
2121

22+
## Development
23+
24+
Install development dependencies including pre-commit:
25+
26+
```bash
27+
uv sync --extra dev
28+
```
29+
30+
Set up pre-commit hooks:
31+
32+
```bash
33+
uv run pre-commit install
34+
```
35+
36+
Run pre-commit manually:
37+
38+
```bash
39+
uv run pre-commit run --all-files
40+
```
41+
2242
## License
2343

2444
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

eoapi_notifier/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import re
66
from pathlib import Path
77

8+
89
def get_version():
910
"""Get version from pyproject.toml."""
1011
try:
@@ -15,10 +16,13 @@ def get_version():
1516
except Exception:
1617
return "unknown"
1718

19+
1820
__version__ = get_version()
1921

22+
2023
def version():
2124
print(f"Version: {__version__}")
2225

26+
2327
if __name__ == "__main__":
2428
version()

pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,10 @@ authors = [
1414
[project.optional-dependencies]
1515
test = [
1616
"pytest>=8.4.2",
17+
"pytest-cov",
18+
]
19+
dev = [
20+
"pre-commit",
21+
"mypy",
22+
"ruff",
1723
]

tests/test_notifier.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from io import StringIO
77
from unittest.mock import patch
88

9-
import pytest
109

1110
from eoapi_notifier import get_version, version, __version__
1211

@@ -28,7 +27,7 @@ def test_version_attribute():
2827

2928
def test_version_function():
3029
"""Test that version function prints expected output."""
31-
with patch('sys.stdout', new=StringIO()) as fake_out:
30+
with patch("sys.stdout", new=StringIO()) as fake_out:
3231
version()
3332
output = fake_out.getvalue()
3433
assert "Version:" in output

0 commit comments

Comments
 (0)