From ef55fbe603b724863fb476ff3ab57d1b40fe28c8 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sat, 2 Nov 2024 11:47:28 +0100 Subject: [PATCH 1/2] pipx run ruff check --fix --unsafe-fixes --- example/repeatvoice.py | 2 +- pyproject.toml | 5 +++++ pyttsx3/drivers/_espeak.py | 2 +- pyttsx3/drivers/espeak.py | 2 +- tests/test_pyttsx3.py | 2 +- 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/example/repeatvoice.py b/example/repeatvoice.py index dfa2f33..afd0fb2 100644 --- a/example/repeatvoice.py +++ b/example/repeatvoice.py @@ -15,7 +15,7 @@ def text_to_speech(text): def speech_to_text(): r = s.Recognizer() # an object r which recognises the voice - with s.Microphone() as source: + with s.Microphone(): # when using with statement. The with statement itself ensures proper acquisition and release of resources print(r.recognize_google(audio)) text_to_speech(r.recognize_google(audio)) diff --git a/pyproject.toml b/pyproject.toml index b67ba69..e22723c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -52,3 +52,8 @@ urls = { Homepage = "https://github.com/nateshmbhat/pyttsx3" } [tool.setuptools] packages = [ "pyttsx3", "pyttsx3.drivers" ] include-package-data = false + +[tool.ruff] +target-version = "py39" +line-length = 88 +lint.extend-ignore = [ "F403", "F405", "F821" ] diff --git a/pyttsx3/drivers/_espeak.py b/pyttsx3/drivers/_espeak.py index 8ffe769..3bd7a9e 100644 --- a/pyttsx3/drivers/_espeak.py +++ b/pyttsx3/drivers/_espeak.py @@ -61,7 +61,7 @@ def load_library(): raise RuntimeError( "This means you probably do not have eSpeak or eSpeak-ng installed!" ) -except Exception as exp: +except Exception: raise # constants and such from speak_lib.h diff --git a/pyttsx3/drivers/espeak.py b/pyttsx3/drivers/espeak.py index 17a4f75..40763e1 100644 --- a/pyttsx3/drivers/espeak.py +++ b/pyttsx3/drivers/espeak.py @@ -76,7 +76,7 @@ def getProperty(name: str): "utf-8", errors="ignore" ) kwargs["languages"] = [language_code] - except UnicodeDecodeError as e: + except UnicodeDecodeError: kwargs["languages"] = ["Unknown"] genders = [None, "male", "female"] kwargs["gender"] = genders[v.gender] diff --git a/tests/test_pyttsx3.py b/tests/test_pyttsx3.py index 8003e48..7f4a2c0 100644 --- a/tests/test_pyttsx3.py +++ b/tests/test_pyttsx3.py @@ -1,10 +1,10 @@ from __future__ import annotations import sys +import wave from unittest import mock import pytest -import wave import pyttsx3 From 7a1fa835db4c9ee89efb998f2ecc8c3fcb4c1526 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 4 Nov 2024 11:40:49 +0100 Subject: [PATCH 2/2] pre-commit: Add ruff check --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 79fc78a..01d27ce 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -52,4 +52,4 @@ repos: rev: v0.7.2 hooks: # Format before linting - id: ruff-format - # - id: ruff + - id: ruff