Skip to content

Commit 2eca765

Browse files
authoredMay 3, 2024··
use ruff instead of black (#598)
1 parent e776722 commit 2eca765

11 files changed

+38
-71
lines changed
 

‎.github/workflows/docs.yaml

+10-7
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,25 @@ jobs:
1010

1111
runs-on: ubuntu-latest
1212
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
1316
- name: Setup Python
14-
uses: actions/setup-python@v4
17+
uses: actions/setup-python@v5
1518
with:
1619
python-version: '3.x'
1720
architecture: 'x64'
18-
19-
- name: Checkout
20-
uses: actions/checkout@v4
21+
cache: "pip"
22+
cache-dependency-path: |
23+
requirements.txt
24+
docs/requirements.txt
2125
2226
- name: Build
23-
shell: bash
2427
run: |
2528
pip install -r requirements.txt
2629
make cython
2730
2831
- name: Sphinx Documentation Generator
2932
run: |
30-
pip install tox
31-
tox -e sphinx
33+
pip install -r docs/requirements.txt
34+
make docs
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
1-
name: Black
1+
name: lint
22

33
on: ["push", "pull_request"]
44

55
jobs:
6-
black:
6+
lint:
77
# We want to run on external PRs, but not on our own internal PRs as they'll be run
88
# by the push to the branch.
99
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
1010

1111
runs-on: ubuntu-latest
1212
steps:
13-
- name: Setup Python
14-
uses: actions/setup-python@v4
15-
with:
16-
python-version: '3.x'
17-
architecture: 'x64'
18-
1913
- name: Checkout
2014
uses: actions/checkout@v4
2115

22-
- name: Black Code Formatter
16+
- name: ruff check
17+
run: |
18+
pipx run ruff check --diff msgpack/ test/ setup.py
19+
20+
- name: ruff format
2321
run: |
24-
pip install black==22.3.0
25-
black -S --diff --check msgpack/ test/ setup.py
22+
pipx run ruff format --diff msgpack/ test/ setup.py

‎Makefile

+11-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,17 @@ PYTHON_SOURCES = msgpack test setup.py
44
all: cython
55
python setup.py build_ext -i -f
66

7-
.PHONY: black
8-
black:
9-
black $(PYTHON_SOURCES)
7+
.PHONY: format
8+
format:
9+
pipx run ruff format $(PYTHON_SOURCES)
10+
11+
.PHONY: lint
12+
lint:
13+
pipx run ruff check $(PYTHON_SOURCES)
14+
15+
.PHONY: doc
16+
doc:
17+
cd docs && sphinx-build -n -v -W --keep-going -b html -d doctrees . html
1018

1119
.PHONY: pyupgrade
1220
pyupgrade:

‎docs/requirements.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
sphinx~=7.2
2-
sphinx-rtd-theme~=1.3.0
1+
sphinx~=7.3.7
2+
sphinx-rtd-theme~=2.0.0

‎msgpack/fallback.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Fallback pure Python implementation of msgpack"""
2+
23
from datetime import datetime as _DateTime
34
import sys
45
import struct

‎pyproject.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ skip_string_normalization = true
5454
[tool.ruff]
5555
line-length = 100
5656
target-version = "py38"
57-
ignore = []
57+
lint.ignore = []
5858

59-
[tool.ruff.per-file-ignores]
59+
[tool.ruff.lint.per-file-ignores]
6060
"msgpack/__init__.py" = ["F401", "F403"]
6161
"msgpack/fallback.py" = ["E731"]
6262
"test/test_seq.py" = ["E501"]

‎requirements.txt

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,2 @@
11
# Also declared in pyproject.toml, if updating here please also update there.
2-
Cython~=3.0.8
3-
4-
# Tools required only for development. No need to add it to pyproject.toml file.
5-
black==23.3.0
6-
pytest==7.3.1
7-
pyupgrade==3.3.2
2+
Cython~=3.0.10

‎test/test_memoryview.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,4 @@ def test_multidim_memoryview():
9595
view = memoryview(b"\00" * 6)
9696
data = view.cast(view.format, (3, 2))
9797
packed = packb(data)
98-
assert packed == b'\xc4\x06\x00\x00\x00\x00\x00\x00'
98+
assert packed == b"\xc4\x06\x00\x00\x00\x00\x00\x00"

‎test/test_pack.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def testStrictUnicodeUnpack():
8989

9090
def testIgnoreErrorsPack():
9191
re = unpackb(
92-
packb("abc\uDC80\uDCFFdef", use_bin_type=True, unicode_errors="ignore"),
92+
packb("abc\udc80\udcffdef", use_bin_type=True, unicode_errors="ignore"),
9393
raw=False,
9494
use_list=1,
9595
)

‎test/test_read_size.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Test Unpacker's read_array_header and read_map_header methods"""
2+
23
from msgpack import packb, Unpacker, OutOfData
34

45
UnexpectedTypeException = ValueError

‎tox.ini

-38
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.