Skip to content

Commit

Permalink
Replaces black with ruff (#94)
Browse files Browse the repository at this point in the history
* Upgrades ruff

* refactor: makefile

- removes redundant commands
- groups multiple commands by context
- removes black formatter
- new command format
- Updates CONTRIBUTING.rst

* fix: formatting caught by ruff

* Removes black dependency

* Removes .PHONY leftover

Co-authored-by: Lucas Carvalho <[email protected]>

* Fixes PHONY when moving sectons in file

Co-authored-by: Lucas Carvalho <[email protected]>

* Cleans `lint` recipe and adds format checking

Co-authored-by: Lucas Carvalho <[email protected]>

* Adds linting fixes to format recipe

Co-authored-by: Lucas Carvalho <[email protected]>

---------

Co-authored-by: Lucas Carvalho <[email protected]>
  • Loading branch information
girol and zsinx6 authored Jul 10, 2024
1 parent 9ffb3bc commit ff0f537
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 157 deletions.
6 changes: 5 additions & 1 deletion CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ How to Run Dojo-Toolkit Tests
-----------------------------

After installing the depencencies, simply run:

::

$ make test
Expand All @@ -62,4 +61,9 @@ After installing the depencencies, simply run:
Coding Style
------------

To run the linters
::

$ make lint

`PEP8 <https://www.python.org/dev/peps/pep-0008/>`_ with line lenght up to 99 characters.
69 changes: 24 additions & 45 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
SHELL := bash

.PHONY: install
install:
poetry install

.PHONY: test
test:
poetry run pytest -vv --cov=dojo_toolkit --cov-report=term-missing

.PHONY: lint
lint:
poetry check --lock
poetry run ruff check .
poetry run ruff format . --check

.PHONY: format
format:
poetry run ruff check . --fix
poetry run ruff format .

.PHONY: build
build: clean
poetry build
.PHONY: clean
clean: clean-eggs clean-build
@find . -iname '*.pyc' -delete
Expand All @@ -16,48 +40,3 @@ clean-build:
@rm -fr build/
@rm -fr dist/
@rm -fr *.egg-info

.PHONY: ruff
ruff:
poetry run ruff . --fix

.PHONY: ruffcheck
ruffcheck:
@echo "Checking ruff..."
poetry run ruff .

.PHONY: black
black:
poetry run black .

.PHONY: blackcheck
blackcheck:
@echo "Checking black..."
poetry run black --check --diff .

.PHONY: build
build: clean
poetry build

.PHONY: install
install:
poetry install

.PHONY: poetrycheck
poetrycheck:
poetry lock --check

.PHONY: pyformatcheck
pyformatcheck: poetrycheck blackcheck ruffcheck

.PHONY: lint
lint: pyformatcheck

.PHONY: format
format: ruff black

.PHONY: test
test:
poetry run pytest -vv --cov=dojo_toolkit --cov-report=term-missing

SHELL := bash
1 change: 1 addition & 0 deletions dojo_toolkit/test_runner.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Module for running tests like doctest and unittest
"""

import os
import subprocess

Expand Down
126 changes: 22 additions & 104 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ typer = {extras = ["all"], version = "^0.9.0"}
[tool.poetry.group.dev.dependencies]
pytest = "^7.4.0"
pytest-cov = "^4.1.0"
black = "^23.7.0"
coverage = {extras = ["toml"], version = "^6.1.2"}
ruff = "^0.0.278"
ruff = "^0.5.1"

[tool.pytest.ini_options]
minversion = "7.0"
Expand All @@ -32,15 +31,15 @@ line-length = 100
[tool.ruff]
target-version = "py311"
line-length = 100
select = [
lint.select = [
"I", # isort
"C4", # flake8-comprehensions
"F", # pyflakes
"E", # pycodestyle
"TID", # flake8-tidy-imports
"C901", # mccabe
]
ignore = [
lint.ignore = [
"E501", # line too long, handled by black
"C401", # generator syntax for sets vs always force set comprehension
"PLC0414", # allow explicit re-exports using 'as' without forcing __all__
Expand Down
8 changes: 5 additions & 3 deletions tests/test_dojo.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@

@pytest.fixture
def mocked_dojo():
with mock.patch("dojo_toolkit.dojo.Observer"), mock.patch(
"dojo_toolkit.dojo.Timer"
), mock.patch("dojo_toolkit.dojo.SoundHandler"):
with (
mock.patch("dojo_toolkit.dojo.Observer"),
mock.patch("dojo_toolkit.dojo.Timer"),
mock.patch("dojo_toolkit.dojo.SoundHandler"),
):
return Dojo("/foo/bar", test_runner=mock.Mock())


Expand Down

0 comments on commit ff0f537

Please sign in to comment.