Skip to content

Commit

Permalink
Implement ruff check and format everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
pydanny committed Oct 29, 2023
1 parent 65e7b3e commit c5298be
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 36 deletions.
19 changes: 15 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,25 @@ jobs:
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- name: Install dependencies
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
pip install clarifai_grpc
pip install -e '.[test]'
sudo apt-get update
sudo apt-get install -y ffmpeg
sudo apt-get install -y ffmpeg
- name: Lint the code
run: |
ruff check .
- name: Format the code
run: |
ruff format .
- name: Install ffmpeg
run: |
sudo apt-get update
sudo apt-get install -y ffmpeg
- name: Find and run pytest tests
run: |
Expand Down
1 change: 0 additions & 1 deletion src/interviewkit/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
import os, sys; sys.path.append(os.path.dirname(os.path.realpath(__file__)))
7 changes: 4 additions & 3 deletions src/interviewkit/cli.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from pathlib import Path

import typer
from questions import generate_questions_from_transcript
from slicer import audio_slicing
from transcript import transcribe_from_paths
from typing_extensions import Annotated

from .questions import generate_questions_from_transcript
from .slicer import audio_slicing
from .transcript import transcribe_from_paths


__version__ = "0.0.1"

Expand Down
4 changes: 2 additions & 2 deletions src/interviewkit/interview.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from enum import StrEnum, auto

from interviewee import Interviewee
from transcript import Transcript
from .interviewee import Interviewee
from .transcript import Transcript


class Status(StrEnum):
Expand Down
9 changes: 4 additions & 5 deletions src/interviewkit/main.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@

from interview import Interview
from interviewee import Gender, Interviewee
from settings import Settings
from transcript import Transcript
from .interview import Interview
from .interviewee import Gender, Interviewee
from .settings import Settings
from .transcript import Transcript


settings = Settings()
Expand Down
17 changes: 11 additions & 6 deletions tests/test_cli_version.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
import pytest
import subprocess

import pytest


@pytest.fixture
def run_cli_command():
# This fixture runs the CLI command and captures its output
def run_command():
# Run the CLI command and capture its output
result = subprocess.run(["python", "-m", "src.interviewkit.cli", "version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
result = subprocess.run(
["python", "-m", "src.interviewkit.cli", "version"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True,
)
return result

return run_command


class TestCLIVersion():

class TestCLIVersion:
def test_version_option(self, run_cli_command):
result = run_cli_command()

assert result.returncode == 0

# Check if the version number is correct
assert f"HistoryAIToolKit: 0.0.1" in result.stdout
assert "HistoryAIToolKit: 0.0.1" in result.stdout
29 changes: 14 additions & 15 deletions tests/test_install_package.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
import shutil
import subprocess
import sys

import pytest
import shutil


@pytest.fixture
def create_venv(tmp_path):
venv_dir = tmp_path / ".venv"
subprocess.run([sys.executable, "-m", "venv", str(venv_dir)], check=True)
yield venv_dir
shutil.rmtree(venv_dir)
yield venv_dir
shutil.rmtree(venv_dir)


def test_install_in_editable_mode(create_venv):
activate_script = create_venv / "bin" / "activate" if sys.platform != "win32" else create_venv / "Scripts" / "activate"
activate_script = (
create_venv / "bin" / "activate"
if sys.platform != "win32"
else create_venv / "Scripts" / "activate"
)
shell = False if sys.platform != "win32" else True


commands = [
f"source {activate_script}",
"pip install -e '.[test]'"
]



commands = [f"source {activate_script}", "pip install -e '.[test]'"]

process = subprocess.Popen(["/bin/bash", "-c", " && ".join(commands)], shell=shell)
process.communicate()


assert process.returncode == 0, "Installation in editable mode failed"

assert process.returncode == 0, "Installation in editable mode failed"

0 comments on commit c5298be

Please sign in to comment.