Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Ruff for code formatting instead of Black #737

Merged
merged 3 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .github/workflows/python-lint-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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'
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) (#737)


## 1.14

Expand Down
6 changes: 3 additions & 3 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
497 changes: 206 additions & 291 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
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
12 changes: 6 additions & 6 deletions vpype/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
2 changes: 1 addition & 1 deletion vpype/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
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

Check warning on line 171 in vpype/text.py

View check run for this annotation

Codecov / codecov/patch

vpype/text.py#L171

Added line #L171 was not covered by tests
w = measure_func(xa)
if w <= width:
result.append(xa)
Expand Down
Loading