Skip to content

Commit 4e434ed

Browse files
authored
Handle linting
* Handle linting Run ruff; remove unused imports; add ruff and pre-commit to dev dependencies; add linter pre-commit hook; update README for developers; add lint check to GitHub workflow * Cross-platform dev installation quotations For greatest cross-platform compatibility, suggest using double-quotes with pip install -e ".[dev]"
1 parent 2aa170f commit 4e434ed

File tree

8 files changed

+36
-7
lines changed

8 files changed

+36
-7
lines changed

.github/workflows/run-tests.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ jobs:
2424
run: pip install .[dev]
2525
shell: bash
2626

27+
- name: run Ruff linter
28+
run: ruff check .
29+
shell: bash
30+
2731
- name: run test
2832
run: pytest -rs
2933
shell: bash

.pre-commit-config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.11.2
4+
hooks:
5+
- id: ruff
6+

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,3 +160,21 @@ file_paths = gather_file_paths(input_path, ignore_file=ignore_file)
160160
sum = checksum_file("examples/example_content/file.txt", algorithm=alg)
161161
# or sum = checksum_file("examples/example_content/file.txt")
162162
```
163+
164+
## Development
165+
To develop the package further:
166+
167+
1. Clone the repository and create a branch
168+
2. Install with dev dependencies:
169+
```bash
170+
pip install -e ".[dev]"
171+
```
172+
3. Install pre-commit hook
173+
```bash
174+
pre-commit install
175+
pre-commit autoupdate # optionally update
176+
```
177+
4. Run tests:
178+
```bash
179+
pytest
180+
```

pyproject.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ dependencies = [
2626
]
2727

2828
[project.optional-dependencies]
29-
dev = ["pytest"]
29+
dev = [
30+
"pytest",
31+
"ruff",
32+
"pre-commit"
33+
]
3034

3135
keywords = [
3236
"checksum",

src/sumbuddy/__main__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import argparse
22
from sumbuddy.hasher import Hasher
33
from sumbuddy.mapper import Mapper
4-
from sumbuddy.filter import Filter
54
from sumbuddy.exceptions import EmptyInputDirectoryError, NoFilesAfterFilteringError, LengthUsedForFixedLengthHashError
65
import csv
76
import hashlib

tests/test_filter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
import unittest
33
import os
4-
from unittest.mock import patch, MagicMock
4+
from unittest.mock import patch
55
from sumbuddy.filter import Filter
66
from sumbuddy.hasher import Hasher
77

tests/test_getChecksums.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import unittest
2-
from unittest.mock import patch, mock_open, MagicMock
2+
from unittest.mock import patch, mock_open
33
import os
4-
import sys
5-
import hashlib
64
from io import StringIO
75

86
from sumbuddy import get_checksums

tests/test_mapper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22
import tempfile
33
import unittest
4-
from unittest.mock import patch, mock_open, MagicMock
4+
from unittest.mock import patch, mock_open
55
from sumbuddy.mapper import Mapper
66
from sumbuddy.filter import Filter
77
from sumbuddy.exceptions import EmptyInputDirectoryError, NoFilesAfterFilteringError, NotADirectoryError

0 commit comments

Comments
 (0)