Skip to content

Commit

Permalink
use ruff instead of black
Browse files Browse the repository at this point in the history
  • Loading branch information
methane committed May 3, 2024
1 parent e776722 commit 2298070
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 71 deletions.
19 changes: 8 additions & 11 deletions .github/workflows/black.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
name: Black
name: lint

on: ["push", "pull_request"]

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

runs-on: ubuntu-latest
steps:
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
architecture: 'x64'

- name: Checkout
uses: actions/checkout@v4

- name: Black Code Formatter
- name: ruff check
run: |
pipx run ruff check --diff msgpack/ test/ setup.py
- name: ruff format
run: |
pip install black==22.3.0
black -S --diff --check msgpack/ test/ setup.py
pipx run ruff format --diff msgpack/ test/ setup.py
17 changes: 10 additions & 7 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,25 @@ jobs:

runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.x'
architecture: 'x64'

- name: Checkout
uses: actions/checkout@v4
cache: "pip"
cache-dependency-path: |
requirements.txt
docs/requirements.txt
- name: Build
shell: bash
run: |
pip install -r requirements.txt
make cython
- name: Sphinx Documentation Generator
run: |
pip install tox
tox -e sphinx
pip install -r docs/requirements.txt
make docs
14 changes: 11 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,17 @@ PYTHON_SOURCES = msgpack test setup.py
all: cython
python setup.py build_ext -i -f

.PHONY: black
black:
black $(PYTHON_SOURCES)
.PHONY: format
format:
pipx run ruff format $(PYTHON_SOURCES)

.PHONY: lint
lint:
pipx run ruff check $(PYTHON_SOURCES)

.PHONY: doc
doc:
cd docs && sphinx-build -n -v -W --keep-going -b html -d doctrees . html

.PHONY: pyupgrade
pyupgrade:
Expand Down
4 changes: 2 additions & 2 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
sphinx~=7.2
sphinx-rtd-theme~=1.3.0
sphinx~=7.3.7
sphinx-rtd-theme~=2.0.0
1 change: 1 addition & 0 deletions msgpack/fallback.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Fallback pure Python implementation of msgpack"""

from datetime import datetime as _DateTime
import sys
import struct
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ skip_string_normalization = true
[tool.ruff]
line-length = 100
target-version = "py38"
ignore = []
lint.ignore = []

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"msgpack/__init__.py" = ["F401", "F403"]
"msgpack/fallback.py" = ["E731"]
"test/test_seq.py" = ["E501"]
7 changes: 1 addition & 6 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
# Also declared in pyproject.toml, if updating here please also update there.
Cython~=3.0.8

# Tools required only for development. No need to add it to pyproject.toml file.
black==23.3.0
pytest==7.3.1
pyupgrade==3.3.2
Cython~=3.0.10
2 changes: 1 addition & 1 deletion test/test_memoryview.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,4 @@ def test_multidim_memoryview():
view = memoryview(b"\00" * 6)
data = view.cast(view.format, (3, 2))
packed = packb(data)
assert packed == b'\xc4\x06\x00\x00\x00\x00\x00\x00'
assert packed == b"\xc4\x06\x00\x00\x00\x00\x00\x00"
2 changes: 1 addition & 1 deletion test/test_pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def testStrictUnicodeUnpack():

def testIgnoreErrorsPack():
re = unpackb(
packb("abc\uDC80\uDCFFdef", use_bin_type=True, unicode_errors="ignore"),
packb("abc\udc80\udcffdef", use_bin_type=True, unicode_errors="ignore"),
raw=False,
use_list=1,
)
Expand Down
1 change: 1 addition & 0 deletions test/test_read_size.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test Unpacker's read_array_header and read_map_header methods"""

from msgpack import packb, Unpacker, OutOfData

UnexpectedTypeException = ValueError
Expand Down
38 changes: 0 additions & 38 deletions tox.ini

This file was deleted.

0 comments on commit 2298070

Please sign in to comment.