Skip to content

Commit 0b35af4

Browse files
committed
fix linting
1 parent 9d27ff2 commit 0b35af4

File tree

6 files changed

+12
-19
lines changed

6 files changed

+12
-19
lines changed

src/rb-api/rb/api/main.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
from logging.config import dictConfig
21
import multiprocessing
32
import os
4-
import logging
53
import sys
6-
from starlette.middleware.base import BaseHTTPMiddleware
74
from fastapi import FastAPI
85
from fastapi.staticfiles import StaticFiles
96
from rb.api import routes

src/rb-api/rb/api/routes/cli.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def wrapper(*args, **kwargs) -> ResponseBody:
157157
)
158158
# FIXME: prefix /api to make desktop call happy for now , eventually this will go away
159159
# GOAL : /audio/routes is valid /api/routes should no longer work
160-
cli_to_api_router.include_router(router,prefix=f'/api', tags=[plugin.name])
160+
cli_to_api_router.include_router(router,prefix='/api', tags=[plugin.name])
161161

162162
logger.debug(f"Registering FastAPI route for {plugin.name} desktop call: {command.callback.__name__}")
163163
else:

src/rb-api/rb/api/utils.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
from typing import Any, Callable
21
import argparse
2+
from typing import Any, Callable
3+
34
from rb.api.models import FloatRangeDescriptor, IntRangeDescriptor
45

56

67
def get_int_range_check_func_arg_parser(range: IntRangeDescriptor) -> Callable[[Any], int]:
78
def check_func(value: Any) -> int:
89
try:
910
value = int(value)
10-
except:
11+
except Exception:
1112
raise argparse.ArgumentTypeError(f"{value} is not a valid integer")
1213
if value < range.min or value > range.max:
1314
raise argparse.ArgumentTypeError(f"{value} is not in the range [{range.min}, {range.max}]")
@@ -18,7 +19,7 @@ def get_float_range_check_func_arg_parser(range: FloatRangeDescriptor) -> Callab
1819
def check_func(value: Any) -> float:
1920
try:
2021
value = float(value)
21-
except:
22+
except Exception:
2223
raise argparse.ArgumentTypeError(f"{value} is not a valid float")
2324
if value < range.min or value > range.max:
2425
raise argparse.ArgumentTypeError(f"{value} is not in the range [{range.min}, {range.max}]")

src/rb-audio-transcription/rb_audio_transcription/main.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""audio transcribe plugin"""
2-
import sys, os
2+
import sys
33
import json
44
import logging
55
from pathlib import Path
@@ -8,7 +8,6 @@
88
from rb.api.models import (
99
BatchTextResponse,
1010
DirectoryInput,
11-
FileInput,
1211
FloatParameterDescriptor,
1312
InputSchema,
1413
InputType,
@@ -21,7 +20,6 @@
2120
TextParameterDescriptor,
2221
TextResponse,
2322
)
24-
from rb.api.models import BatchFileInput
2523
from rb.api.models import API_APPMETDATA, API_ROUTES, PLUGIN_SCHEMA_SUFFIX
2624
from rb.api.utils import (
2725
get_int_range_check_func_arg_parser,
@@ -190,7 +188,7 @@ def alternate_params_parser(p: str) -> ParameterSchema:
190188
# this fucntion is not used , just an example
191189
try:
192190
params = string_to_dict(p)
193-
logger.info(f"-----DEBUG parser ---")
191+
logger.info("-----DEBUG parser ---")
194192
range_object = IntRangeDescriptor(min=params["c"], max=params["d"])
195193
func = get_int_range_check_func_arg_parser(range_object)
196194
if func(params["e"]):
@@ -221,15 +219,15 @@ def validate_inputs(inputs: DirInputs):
221219
files = [file for file in dirpath.iterdir() if file.is_file()]
222220
logger.debug(files)
223221
if len(files) < 1:
224-
raise HTTPException(status_code=400, detail=f"no 'files_in given directory' for transcribe command")
222+
raise HTTPException(status_code=400, detail="no 'files_in given directory' for transcribe command")
225223
logger.debug("------validate inputs done ---")
226224
## this return object is now ready for use in transcribe function
227225
return inputs
228226
except (Exception) as e:
229227
logger.error("validate bad inputs: %s", e)
230228
raise HTTPException(status_code=400, detail=f"Invalid path inputs for transcribe command: {e}")
231229

232-
@app.command(f'transcribe')
230+
@app.command('transcribe')
233231
def transcribe(
234232
inputs: Annotated[
235233
DirInputs,

src/rb-audio-transcription/tests/test_main.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,19 @@
2424
def test_routes_command():
2525
''' call typer cli to get routes'''
2626
result = runner.invoke(cli_app, [API_ROUTES])
27-
assert result is not ""
27+
assert result != ""
2828
assert result.exit_code == 0
2929

3030

3131
def test_metadata_command():
3232
result = runner.invoke(cli_app, [API_APPMETDATA])
33-
assert result is not ""
33+
assert result != ""
3434
assert result.exit_code == 0
3535

3636

3737
def test_schema_command():
3838
result = runner.invoke(cli_app, [f"task{PLUGIN_SCHEMA_SUFFIX}"])
39-
assert result is not ""
39+
assert result != ""
4040
assert result.exit_code == 0
4141

4242
def test_negative_test():

src/rb-lib/rb/lib/stdout.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import contextlib
21
import io
32
import sys
43
from io import StringIO
5-
from typing import Callable, Generator
64

75

86
class Capturing(list):
@@ -19,7 +17,6 @@ def __exit__(self, *args):
1917

2018
def capture_stdout_as_generator(func, *args, **kwargs):
2119
import sys
22-
import io
2320

2421
old_stdout = sys.stdout
2522
sys.stdout = buffer = io.StringIO()

0 commit comments

Comments
 (0)