Skip to content

Commit 49c68c1

Browse files
Add pre-commit hooks to CI (#18)
1 parent d9993f8 commit 49c68c1

File tree

4 files changed

+48
-4
lines changed

4 files changed

+48
-4
lines changed

.github/workflows/lint.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
lint:
15+
runs-on: ubuntu-latest
16+
timeout-minutes: 10
17+
18+
steps:
19+
- uses: actions/checkout@v5
20+
with:
21+
persist-credentials: false
22+
23+
- uses: actions/setup-python@v6
24+
with:
25+
python-version: "3.x"
26+
27+
- uses: pre-commit/action@v3.0.1

.pre-commit-config.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
repos:
2+
- repo: https://github.com/psf/black
3+
rev: 24.10.0
4+
hooks:
5+
- id: black
6+
language_version: python3
7+
8+
- repo: https://github.com/pre-commit/pre-commit-hooks
9+
rev: v5.0.0
10+
hooks:
11+
- id: trailing-whitespace
12+
- id: end-of-file-fixer
13+
- id: check-yaml
14+
- id: check-added-large-files
15+
- id: check-merge-conflict
16+
- id: mixed-line-ending

iconvcodec.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,11 @@ def _iconv_decode_impl(decoder, msg, errors, bufsize=None):
8181

8282
def codec_factory(encoding):
8383
# Workaround for https://github.com/bodograumann/python-iconv/issues/4
84-
_encoding = encoding \
85-
.replace("_translit", "//TRANSLIT") \
86-
.replace("_ignore", "//IGNORE") \
84+
_encoding = (
85+
encoding.replace("_translit", "//TRANSLIT")
86+
.replace("_ignore", "//IGNORE")
8787
.replace("_non_identical_discard", "//NON_IDENTICAL_DISCARD")
88+
)
8889

8990
encoder = iconv.open(_encoding, "utf-8")
9091
decoder = iconv.open("utf-8", _encoding)

setup.py

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

44
# On Linux, iconv is part of glibc and doesn't need separate linkage
55
# Otherwise, link against libiconv
6-
if sys.platform.startswith('linux'):
6+
if sys.platform.startswith("linux"):
77
libraries = []
88
else:
99
libraries = ["iconv"]

0 commit comments

Comments
 (0)