diff --git a/src/openai/_utils/_utils.py b/src/openai/_utils/_utils.py index d2bfc91a70..83f88cc3e7 100644 --- a/src/openai/_utils/_utils.py +++ b/src/openai/_utils/_utils.py @@ -230,7 +230,7 @@ def human_join(seq: Sequence[str], *, delim: str = ", ", final: str = "or") -> s def quote(string: str) -> str: """Add single quotation marks around the given string. Does *not* do any escaping.""" - return "'" + string + "'" + return f"'{string}'" def required_args(*variants: Sequence[str]) -> Callable[[CallableT], CallableT]: diff --git a/src/openai/lib/_validators.py b/src/openai/lib/_validators.py index c8608c0cef..ae48aafa88 100644 --- a/src/openai/lib/_validators.py +++ b/src/openai/lib/_validators.py @@ -309,10 +309,10 @@ def common_completion_prefix_validator(df: pd.DataFrame) -> Remediation: return Remediation(name="common_prefix") def remove_common_prefix(x: Any, prefix: Any, ws_prefix: Any) -> Any: - x["completion"] = x["completion"].str[len(prefix) :] + x["completion"] = x["completion"].str[len(prefix):] if ws_prefix: # keep the single whitespace as prefix - x["completion"] = " " + x["completion"] + x["completion"] = f" {x['completion']}" return x if (df.completion == common_prefix).all(): @@ -624,7 +624,7 @@ def get_outfnames(fname: str, split: bool) -> list[str]: while True: index_suffix = f" ({i})" if i > 0 else "" candidate_fnames = [ - os.path.splitext(fname)[0] + "_prepared" + suffix + index_suffix + ".jsonl" for suffix in suffixes + f"{os.path.splitext(fname)[0]}_prepared{suffix}{index_suffix}.jsonl" for suffix in suffixes ] if not any(os.path.isfile(f) for f in candidate_fnames): return candidate_fnames diff --git a/tests/test_required_args.py b/tests/test_required_args.py index 1de017db24..5d1a5224ff 100644 --- a/tests/test_required_args.py +++ b/tests/test_required_args.py @@ -43,7 +43,7 @@ def foo(*, a: str | None = None) -> str | None: def test_multiple_params() -> None: @required_args(["a", "b", "c"]) def foo(a: str = "", *, b: str = "", c: str = "") -> str | None: - return a + " " + b + " " + c + return f"{a} {b} {c}" assert foo(a="a", b="b", c="c") == "a b c"