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 and update typer #87

Merged
merged 8 commits into from
Jul 27, 2023
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
8 changes: 0 additions & 8 deletions .flake8

This file was deleted.

8 changes: 6 additions & 2 deletions .github/workflows/test_push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ jobs:
python-version: '3.9'
architecture: 'x64'
- name: "Python Poetry Action"
uses: Gr1N/setup-poetry@v7
- name: "Run tests and linters"
uses: Gr1N/setup-poetry@v8
- name: "Install dev dependencies"
run: make install
- name: "Run linters"
run: make lint
- name: "Run tests"
run: make test
- name: Coveralls
uses: AndreMiras/coveralls-python-action@develop
Expand Down
48 changes: 39 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,33 +1,63 @@
.PHONY: clean
clean: clean-eggs clean-build
@find . -iname '*.pyc' -delete
@find . -iname '*.pyo' -delete
@find . -iname '*~' -delete
@find . -iname '*.swp' -delete
@find . -iname '__pycache__' -delete

.PHONY: clean-eggs
clean-eggs:
@find . -name '*.egg' -print0|xargs -0 rm -rf --
@rm -rf .eggs/

.PHONY: clean-build
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

format: install
poetry run black .
poetry run isort .
.PHONY: poetrycheck
poetrycheck:
poetry lock --check

.PHONY: pyformatcheck
pyformatcheck: poetrycheck blackcheck ruffcheck

.PHONY: lint
lint: pyformatcheck

.PHONY: format
format: ruff black

lint: install
poetry run flake8
poetry run black . --check
poetry run isort . --check-only --diff
.PHONY: test
test:
poetry run pytest -vv --cov=dojo_toolkit --cov-report=term-missing

test: lint
poetry run pytest
SHELL := bash
2 changes: 1 addition & 1 deletion dojo_toolkit/code_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def __init__(self, *args, **kwargs):
self.dojo = kwargs.pop("dojo")
self.test_runner = kwargs.pop("test_runner")

super(DojoCodeHandler, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)

self.last_test_run_time = time.time()

Expand Down
2 changes: 1 addition & 1 deletion dojo_toolkit/dojo.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def __init__(self, code_path, round_time=None, mute=False, test_runner=None, run

def start(self):
self.observer.start()
print("\nWatching: {} folder".format(self.code_path))
print(f"\nWatching: {self.code_path} folder")

self.is_running = True
print("Dojo toolkit started!")
Expand Down
56 changes: 32 additions & 24 deletions dojo_toolkit/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from enum import Enum
from pathlib import Path
from typing import Optional
from typing import Annotated, Optional

import typer

Expand All @@ -13,29 +13,37 @@ class Runners(str, Enum):


def main(
path: Optional[Path] = typer.Argument(
Path("."),
exists=True,
file_okay=False,
dir_okay=True,
readable=True,
help="The path to the folder containing the code used during the dojo",
),
time: Optional[float] = typer.Option(
Dojo.ROUND_TIME,
"--time",
"-t",
help="The amount of time a dojo round lasts",
),
mute: Optional[bool] = typer.Option(
False,
help="Mute all sounds, note: this only works in Linux",
),
runner: Optional[Runners] = typer.Option(
Runners.doctest.value,
"--runner",
help="Name of the runner",
),
path: Annotated[
Optional[Path],
typer.Argument(
exists=True,
file_okay=False,
dir_okay=True,
readable=True,
help="The path to the folder containing the code used during the dojo",
),
] = Path("."),
time: Annotated[
Optional[float],
typer.Option(
"--time",
"-t",
help="The amount of time a dojo round lasts, in minutes",
),
] = Dojo.ROUND_TIME,
mute: Annotated[
Optional[bool],
typer.Option(
help="Mute all sounds, note: this only works in Linux",
),
] = False,
runner: Annotated[
Optional[Runners],
typer.Option(
"--runner",
help="Name of the runner",
),
] = Runners.doctest,
):
dojo = Dojo(
code_path=path.as_posix(), # type: ignore
Expand Down
2 changes: 1 addition & 1 deletion dojo_toolkit/notifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def notify(self, message, image=None):

class GnomeNotifier(BaseNotifier):
def __init__(self):
super(GnomeNotifier, self).__init__()
super().__init__()

self.fail_img = GdkPixbuf.Pixbuf.new_from_file(self.fail_img_path)
self.success_img = GdkPixbuf.Pixbuf.new_from_file(self.success_img_path)
Expand Down
Loading
Loading