Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use Ruff for code formatting instead of Black
Browse files Browse the repository at this point in the history
abey79 committed Jun 3, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 28dd3eb commit 1fa4873
Showing 7 changed files with 232 additions and 238 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/python-lint-tests.yml
Original file line number Diff line number Diff line change
@@ -26,8 +26,13 @@ jobs:

steps:
- uses: actions/checkout@v3

- name: Install Just
uses: extractions/setup-just@v2

- name: Install poetry
run: pipx install poetry!=1.4.1

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
@@ -38,9 +43,7 @@ jobs:
- name: Lint and static analysis
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12' # no need to run that 9x
run: |
poetry run ruff check --output-format=full vpype vpype_cli vpype_viewer tests
poetry run black --check --diff vpype vpype_cli vpype_viewer tests
poetry run mypy
poetry run just lint
# needed for tests to work on ubuntu (libEGL.so.1)
- name: Install EGL mesa
if: matrix.os == 'ubuntu-latest'
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -13,6 +13,10 @@ Release date: UNRELEASED

* Fixed a crash when reading SVG with simplify active (via the `read --simplify` command or the read APIs with `simplify=True`) (thanks to @nataquinones) (#732)

### Other changes

* Use Ruff for code formatting (supersedes Black) (#yyy)


## 1.14

6 changes: 3 additions & 3 deletions justfile
Original file line number Diff line number Diff line change
@@ -11,12 +11,12 @@ test:
pytest

format:
ruff check --fix --output-format=full vpype vpype_cli vpype_viewer tests
ruff format vpype vpype_cli vpype_viewer tests

lint:
mypy
ruff check --output-format=full vpype vpype_cli vpype_viewer tests
black --check --diff vpype vpype_cli vpype_viewer tests
ruff format --check vpype vpype_cli vpype_viewer tests
mypy

# run previously failed tests
test-failed:
434 changes: 211 additions & 223 deletions poetry.lock

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ asteval = ">=0.9.26"
cachetools = ">=4.2.2"
click = ">=8.0.1,<8.2.0"
multiprocess = ">=0.70.11"
numpy = ">=1.25"
numpy = ">=1.25,<2"
pnoise = ">=0.2.0"
pyphen = ">=0.14,<0.16"
scipy = ">=1.6"
@@ -56,7 +56,6 @@ Pillow = { version = ">=9.0.1", optional = true }
PySide6 = { version = ">=6.4.0.1,!=6.6.2", optional = true }

[tool.poetry.group.dev.dependencies]
black = ">=22.3.0"
coverage = {extras = ["toml"], version = ">=5.4"}
mypy = ">=0.901"
packaging = ">=20.8"
12 changes: 6 additions & 6 deletions vpype/config.py
Original file line number Diff line number Diff line change
@@ -51,19 +51,19 @@ class PaperConfig:
] #: location on paper of the (0, 0) plotter unit coordinates

paper_size: tuple[float, float] | None = None #: X/Y axis convention of the plotter
paper_orientation: None | (str) = (
None #: orientation of the plotter coordinate system on paper
)
paper_orientation: None | (
str
) = None #: orientation of the plotter coordinate system on paper
x_range: tuple[int, int] | None = None #: admissible range of X coordinates
y_range: tuple[int, int] | None = None #: admissible range of Y coordinates
origin_location_reference: str | None = "topleft" #: reference for ``origin_location``

info: str = "" #: information printed to the user when paper is used
rotate_180: bool = False #: if True, the geometries are rotated by 180 degrees on the page
set_ps: int | None = None #: if not None, call PS with corresponding value
final_pu_params: None | (str) = (
None #: if not None, these params are added to the final PU command
)
final_pu_params: None | (
str
) = None #: if not None, these params are added to the final PU command
aka_names: list[str] = dataclasses.field(
default_factory=list
) #: alternative paper names (will be found by :func:`paper_config`
2 changes: 1 addition & 1 deletion vpype/text.py
Original file line number Diff line number Diff line change
@@ -168,7 +168,7 @@ def _word_wrap(
w = measure_func(x + a)
if w > width:
for aa, ab in dic.iterate(a) if dic else (): # try hyphenating
xa = x + aa + "\u002D" # our fonts don't have a true hyphen
xa = x + aa + "\u002d" # our fonts don't have a true hyphen
w = measure_func(xa)
if w <= width:
result.append(xa)

0 comments on commit 1fa4873

Please sign in to comment.