Skip to content

Commit

Permalink
- introduce ruff as linter
Browse files Browse the repository at this point in the history
- make ruff and mypy green

Signed-off-by: Florian Schepers <[email protected]>
  • Loading branch information
FlorianSchepers committed May 3, 2024
1 parent 7367e2e commit 3b67d0d
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 11 deletions.
2 changes: 1 addition & 1 deletion meminto/chunking.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def _number_of_tokens_per_chunk(
number_of_chunks = token_count_transcript // token_count_per_chunk + 1
number_of_tokens_per_chunk = token_count_transcript // number_of_chunks + 1

print(f"Spliting transcript in chunks:")
print("Spliting transcript in chunks:")
print(f"LLM max. token count: {max_tokens}")
print(f"Token count of system prompt: {token_count_system_prompt}")
print(f"Token count reserved for response: {token_count_reserved_for_response}")
Expand Down
4 changes: 2 additions & 2 deletions meminto/diarizer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pathlib import Path
from pyannote.audio import Pipeline # type: ignore
from pyannote.core import Annotation # type: ignore
from pyannote.audio import Pipeline
from pyannote.core import Annotation
from meminto.decorators import log_time


Expand Down
2 changes: 1 addition & 1 deletion meminto/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def parse_input_file_path(input_file: str) -> Path:
if not file_path.is_file():
raise Exception(f"Input file path '{file_path}' does not reference a file.")

if not file_path.suffix in ALLOWED_INPUT_FILE_TYPE:
if file_path.suffix not in ALLOWED_INPUT_FILE_TYPE:
raise Exception(
f"Invalid input file type. Only one of the following file type are allowed: {', '.join(str(file_type) for file_type in ALLOWED_INPUT_FILE_TYPE)}"
)
Expand Down
2 changes: 1 addition & 1 deletion meminto/llm/llm.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import requests # type: ignore
import requests


class LLM:
Expand Down
4 changes: 2 additions & 2 deletions meminto/llm/tokenizers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import tiktoken
from transformers import AutoTokenizer, OpenAIGPTTokenizer
from huggingface_hub import login
from huggingface_hub import login


class Tokenizer:
Expand All @@ -13,7 +13,7 @@ def _select_tokenizer(self):
login(token=self.hugging_face_acces_token)
try:
tokenizer = AutoTokenizer.from_pretrained(self.model)
except:
except(Exception):
if self.model in tiktoken.model.MODEL_TO_ENCODING.keys():
tokenizer = OpenAIGPTTokenizer.from_pretrained("openai-gpt")
else:
Expand Down
4 changes: 1 addition & 3 deletions meminto/meeting_minutes_generator.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import os
from typing import Tuple
from meminto.decorators import log_time
from meminto.helpers import Language
from meminto.llm.llm import LLM
Expand All @@ -16,7 +14,7 @@
)
from meminto.llm.tokenizers import Tokenizer
from meminto.transcriber import TranscriptSection
from huggingface_hub import login



class MeetingMinutesGenerator:
Expand Down
42 changes: 41 additions & 1 deletion poetry.lock

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

12 changes: 12 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,19 @@ transformers = "^4.39.3"
pyannote-pipeline = "^3.0.1"
speechbrain = "0.5.15"
python-dotenv = "^1.0.1"

[tool.poetry.group.dev.dependencies]
ruff = "^0.4.2"
mypy = "^1.9.0"
types-requests = "^2.31.0.20240406"

[[tool.mypy.overrides]]
module = [
"transformers",
"huggingface_hub",
"torchaudio",
"pyannote.*",
]
ignore_missing_imports = true


0 comments on commit 3b67d0d

Please sign in to comment.