Skip to content

Commit ec65124

Browse files
chore(internal): reformat imports (#939)
1 parent 7ab050e commit ec65124

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+384
-362
lines changed

pyproject.toml

+19-18
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,16 @@ openai = "openai.cli:main"
4848
[tool.rye]
4949
managed = true
5050
dev-dependencies = [
51-
"pyright==1.1.332",
52-
"mypy==1.7.1",
53-
"black==23.3.0",
54-
"respx==0.20.2",
55-
"pytest==7.1.1",
56-
"pytest-asyncio==0.21.1",
57-
"ruff==0.0.282",
58-
"isort==5.10.1",
59-
"time-machine==2.9.0",
60-
"nox==2023.4.22",
51+
# version pins are in requirements-dev.lock
52+
"pyright",
53+
"mypy",
54+
"black",
55+
"respx",
56+
"pytest",
57+
"pytest-asyncio",
58+
"ruff",
59+
"time-machine",
60+
"nox",
6161
"dirty-equals>=0.6.0",
6262
"azure-identity >=1.14.1",
6363
"types-tqdm > 4"
@@ -68,12 +68,10 @@ format = { chain = [
6868
"format:black",
6969
"format:docs",
7070
"format:ruff",
71-
"format:isort",
7271
]}
7372
"format:black" = "black ."
7473
"format:docs" = "python bin/blacken-docs.py README.md api.md"
7574
"format:ruff" = "ruff --fix ."
76-
"format:isort" = "isort ."
7775

7876
"check:ruff" = "ruff ."
7977

@@ -128,16 +126,13 @@ reportImplicitOverride = true
128126
reportImportCycles = false
129127
reportPrivateUsage = false
130128

131-
[tool.isort]
132-
profile = "black"
133-
length_sort = true
134-
extra_standard_library = ["typing_extensions"]
135-
136129
[tool.ruff]
137130
line-length = 120
138-
format = "grouped"
131+
output-format = "grouped"
139132
target-version = "py37"
140133
select = [
134+
# isort
135+
"I",
141136
# remove unused imports
142137
"F401",
143138
# bare except statements
@@ -155,6 +150,12 @@ unfixable = [
155150
]
156151
ignore-init-module-imports = true
157152

153+
[tool.ruff.lint.isort]
154+
length-sort = true
155+
length-sort-straight = true
156+
combine-as-imports = true
157+
extra-standard-library = ["typing_extensions"]
158+
known-first-party = ["openai", "tests"]
158159

159160
[tool.ruff.per-file-ignores]
160161
"bin/**.py" = ["T201", "T203"]

requirements-dev.lock

+2-3
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ httpcore==1.0.2
3030
httpx==0.25.2
3131
idna==3.4
3232
iniconfig==2.0.0
33-
isort==5.10.1
34-
msal==1.25.0
33+
msal==1.26.0
3534
msal-extensions==1.0.0
3635
mypy==1.7.1
3736
mypy-extensions==1.0.0
@@ -57,7 +56,7 @@ python-dateutil==2.8.2
5756
pytz==2023.3.post1
5857
requests==2.31.0
5958
respx==0.20.2
60-
ruff==0.0.282
59+
ruff==0.1.7
6160
six==1.16.0
6261
sniffio==1.3.0
6362
time-machine==2.9.0

src/openai/__init__.py

+15-14
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@
7272

7373
from .lib import azure as _azure
7474
from .version import VERSION as VERSION
75-
from .lib.azure import AzureOpenAI as AzureOpenAI
76-
from .lib.azure import AsyncAzureOpenAI as AsyncAzureOpenAI
75+
from .lib.azure import AzureOpenAI as AzureOpenAI, AsyncAzureOpenAI as AsyncAzureOpenAI
7776
from .lib._old_api import *
7877

7978
_setup_logging()
@@ -330,15 +329,17 @@ def _reset_client() -> None: # type: ignore[reportUnusedFunction]
330329
_client = None
331330

332331

333-
from ._module_client import beta as beta
334-
from ._module_client import chat as chat
335-
from ._module_client import audio as audio
336-
from ._module_client import edits as edits
337-
from ._module_client import files as files
338-
from ._module_client import images as images
339-
from ._module_client import models as models
340-
from ._module_client import embeddings as embeddings
341-
from ._module_client import fine_tunes as fine_tunes
342-
from ._module_client import completions as completions
343-
from ._module_client import fine_tuning as fine_tuning
344-
from ._module_client import moderations as moderations
332+
from ._module_client import (
333+
beta as beta,
334+
chat as chat,
335+
audio as audio,
336+
edits as edits,
337+
files as files,
338+
images as images,
339+
models as models,
340+
embeddings as embeddings,
341+
fine_tunes as fine_tunes,
342+
completions as completions,
343+
fine_tuning as fine_tuning,
344+
moderations as moderations,
345+
)

src/openai/_client.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
)
2323
from ._utils import is_given, is_mapping, get_async_library
2424
from ._version import __version__
25-
from ._streaming import Stream as Stream
26-
from ._streaming import AsyncStream as AsyncStream
25+
from ._streaming import Stream as Stream, AsyncStream as AsyncStream
2726
from ._exceptions import OpenAIError, APIStatusError
2827
from ._base_client import DEFAULT_MAX_RETRIES, SyncAPIClient, AsyncAPIClient
2928

src/openai/_compat.py

+16-14
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,23 @@ def is_typeddict(type_: type[Any]) -> bool: # noqa: ARG001
4343

4444
else:
4545
if PYDANTIC_V2:
46-
from pydantic.v1.typing import get_args as get_args
47-
from pydantic.v1.typing import is_union as is_union
48-
from pydantic.v1.typing import get_origin as get_origin
49-
from pydantic.v1.typing import is_typeddict as is_typeddict
50-
from pydantic.v1.typing import is_literal_type as is_literal_type
51-
from pydantic.v1.datetime_parse import parse_date as parse_date
52-
from pydantic.v1.datetime_parse import parse_datetime as parse_datetime
46+
from pydantic.v1.typing import (
47+
get_args as get_args,
48+
is_union as is_union,
49+
get_origin as get_origin,
50+
is_typeddict as is_typeddict,
51+
is_literal_type as is_literal_type,
52+
)
53+
from pydantic.v1.datetime_parse import parse_date as parse_date, parse_datetime as parse_datetime
5354
else:
54-
from pydantic.typing import get_args as get_args
55-
from pydantic.typing import is_union as is_union
56-
from pydantic.typing import get_origin as get_origin
57-
from pydantic.typing import is_typeddict as is_typeddict
58-
from pydantic.typing import is_literal_type as is_literal_type
59-
from pydantic.datetime_parse import parse_date as parse_date
60-
from pydantic.datetime_parse import parse_datetime as parse_datetime
55+
from pydantic.typing import (
56+
get_args as get_args,
57+
is_union as is_union,
58+
get_origin as get_origin,
59+
is_typeddict as is_typeddict,
60+
is_literal_type as is_literal_type,
61+
)
62+
from pydantic.datetime_parse import parse_date as parse_date, parse_datetime as parse_datetime
6163

6264

6365
# refactored config

src/openai/_extras/__init__.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
from .numpy_proxy import numpy as numpy
2-
from .numpy_proxy import has_numpy as has_numpy
1+
from .numpy_proxy import numpy as numpy, has_numpy as has_numpy
32
from .pandas_proxy import pandas as pandas

src/openai/_models.py

+4-10
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,11 @@
3030
AnyMapping,
3131
HttpxRequestFiles,
3232
)
33-
from ._utils import (
34-
is_list,
35-
is_given,
36-
is_mapping,
37-
parse_date,
38-
parse_datetime,
39-
strip_not_given,
40-
)
41-
from ._compat import PYDANTIC_V2, ConfigDict
42-
from ._compat import GenericModel as BaseGenericModel
33+
from ._utils import is_list, is_given, is_mapping, parse_date, parse_datetime, strip_not_given
4334
from ._compat import (
35+
PYDANTIC_V2,
36+
ConfigDict,
37+
GenericModel as BaseGenericModel,
4438
get_args,
4539
is_union,
4640
parse_obj,

src/openai/_types.py

+1-8
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,7 @@
1919
Sequence,
2020
AsyncIterator,
2121
)
22-
from typing_extensions import (
23-
Literal,
24-
Protocol,
25-
TypeAlias,
26-
TypedDict,
27-
override,
28-
runtime_checkable,
29-
)
22+
from typing_extensions import Literal, Protocol, TypeAlias, TypedDict, override, runtime_checkable
3023

3124
import pydantic
3225
from httpx import URL, Proxy, Timeout, Response, BaseTransport, AsyncBaseTransport

src/openai/_utils/__init__.py

+40-36
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,41 @@
11
from ._proxy import LazyProxy as LazyProxy
2-
from ._utils import flatten as flatten
3-
from ._utils import is_dict as is_dict
4-
from ._utils import is_list as is_list
5-
from ._utils import is_given as is_given
6-
from ._utils import is_tuple as is_tuple
7-
from ._utils import is_mapping as is_mapping
8-
from ._utils import is_tuple_t as is_tuple_t
9-
from ._utils import parse_date as parse_date
10-
from ._utils import is_sequence as is_sequence
11-
from ._utils import coerce_float as coerce_float
12-
from ._utils import is_list_type as is_list_type
13-
from ._utils import is_mapping_t as is_mapping_t
14-
from ._utils import removeprefix as removeprefix
15-
from ._utils import removesuffix as removesuffix
16-
from ._utils import extract_files as extract_files
17-
from ._utils import is_sequence_t as is_sequence_t
18-
from ._utils import is_union_type as is_union_type
19-
from ._utils import required_args as required_args
20-
from ._utils import coerce_boolean as coerce_boolean
21-
from ._utils import coerce_integer as coerce_integer
22-
from ._utils import file_from_path as file_from_path
23-
from ._utils import parse_datetime as parse_datetime
24-
from ._utils import strip_not_given as strip_not_given
25-
from ._utils import deepcopy_minimal as deepcopy_minimal
26-
from ._utils import extract_type_arg as extract_type_arg
27-
from ._utils import is_required_type as is_required_type
28-
from ._utils import get_async_library as get_async_library
29-
from ._utils import is_annotated_type as is_annotated_type
30-
from ._utils import maybe_coerce_float as maybe_coerce_float
31-
from ._utils import get_required_header as get_required_header
32-
from ._utils import maybe_coerce_boolean as maybe_coerce_boolean
33-
from ._utils import maybe_coerce_integer as maybe_coerce_integer
34-
from ._utils import strip_annotated_type as strip_annotated_type
35-
from ._transform import PropertyInfo as PropertyInfo
36-
from ._transform import transform as transform
37-
from ._transform import maybe_transform as maybe_transform
2+
from ._utils import (
3+
flatten as flatten,
4+
is_dict as is_dict,
5+
is_list as is_list,
6+
is_given as is_given,
7+
is_tuple as is_tuple,
8+
is_mapping as is_mapping,
9+
is_tuple_t as is_tuple_t,
10+
parse_date as parse_date,
11+
is_sequence as is_sequence,
12+
coerce_float as coerce_float,
13+
is_list_type as is_list_type,
14+
is_mapping_t as is_mapping_t,
15+
removeprefix as removeprefix,
16+
removesuffix as removesuffix,
17+
extract_files as extract_files,
18+
is_sequence_t as is_sequence_t,
19+
is_union_type as is_union_type,
20+
required_args as required_args,
21+
coerce_boolean as coerce_boolean,
22+
coerce_integer as coerce_integer,
23+
file_from_path as file_from_path,
24+
parse_datetime as parse_datetime,
25+
strip_not_given as strip_not_given,
26+
deepcopy_minimal as deepcopy_minimal,
27+
extract_type_arg as extract_type_arg,
28+
is_required_type as is_required_type,
29+
get_async_library as get_async_library,
30+
is_annotated_type as is_annotated_type,
31+
maybe_coerce_float as maybe_coerce_float,
32+
get_required_header as get_required_header,
33+
maybe_coerce_boolean as maybe_coerce_boolean,
34+
maybe_coerce_integer as maybe_coerce_integer,
35+
strip_annotated_type as strip_annotated_type,
36+
)
37+
from ._transform import (
38+
PropertyInfo as PropertyInfo,
39+
transform as transform,
40+
maybe_transform as maybe_transform,
41+
)

src/openai/_utils/_utils.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@
2121
import sniffio
2222

2323
from .._types import Headers, NotGiven, FileTypes, NotGivenOr, HeadersLike
24-
from .._compat import is_union as _is_union
25-
from .._compat import parse_date as parse_date
26-
from .._compat import parse_datetime as parse_datetime
24+
from .._compat import is_union as _is_union, parse_date as parse_date, parse_datetime as parse_datetime
2725

2826
_T = TypeVar("_T")
2927
_TupleT = TypeVar("_TupleT", bound=Tuple[object, ...])

src/openai/resources/__init__.py

+7-42
Original file line numberDiff line numberDiff line change
@@ -5,48 +5,13 @@
55
from .audio import Audio, AsyncAudio, AudioWithRawResponse, AsyncAudioWithRawResponse
66
from .edits import Edits, AsyncEdits, EditsWithRawResponse, AsyncEditsWithRawResponse
77
from .files import Files, AsyncFiles, FilesWithRawResponse, AsyncFilesWithRawResponse
8-
from .images import (
9-
Images,
10-
AsyncImages,
11-
ImagesWithRawResponse,
12-
AsyncImagesWithRawResponse,
13-
)
14-
from .models import (
15-
Models,
16-
AsyncModels,
17-
ModelsWithRawResponse,
18-
AsyncModelsWithRawResponse,
19-
)
20-
from .embeddings import (
21-
Embeddings,
22-
AsyncEmbeddings,
23-
EmbeddingsWithRawResponse,
24-
AsyncEmbeddingsWithRawResponse,
25-
)
26-
from .fine_tunes import (
27-
FineTunes,
28-
AsyncFineTunes,
29-
FineTunesWithRawResponse,
30-
AsyncFineTunesWithRawResponse,
31-
)
32-
from .completions import (
33-
Completions,
34-
AsyncCompletions,
35-
CompletionsWithRawResponse,
36-
AsyncCompletionsWithRawResponse,
37-
)
38-
from .fine_tuning import (
39-
FineTuning,
40-
AsyncFineTuning,
41-
FineTuningWithRawResponse,
42-
AsyncFineTuningWithRawResponse,
43-
)
44-
from .moderations import (
45-
Moderations,
46-
AsyncModerations,
47-
ModerationsWithRawResponse,
48-
AsyncModerationsWithRawResponse,
49-
)
8+
from .images import Images, AsyncImages, ImagesWithRawResponse, AsyncImagesWithRawResponse
9+
from .models import Models, AsyncModels, ModelsWithRawResponse, AsyncModelsWithRawResponse
10+
from .embeddings import Embeddings, AsyncEmbeddings, EmbeddingsWithRawResponse, AsyncEmbeddingsWithRawResponse
11+
from .fine_tunes import FineTunes, AsyncFineTunes, FineTunesWithRawResponse, AsyncFineTunesWithRawResponse
12+
from .completions import Completions, AsyncCompletions, CompletionsWithRawResponse, AsyncCompletionsWithRawResponse
13+
from .fine_tuning import FineTuning, AsyncFineTuning, FineTuningWithRawResponse, AsyncFineTuningWithRawResponse
14+
from .moderations import Moderations, AsyncModerations, ModerationsWithRawResponse, AsyncModerationsWithRawResponse
5015

5116
__all__ = [
5217
"Completions",

src/openai/resources/audio/__init__.py

+2-12
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,8 @@
11
# File generated from our OpenAPI spec by Stainless.
22

33
from .audio import Audio, AsyncAudio, AudioWithRawResponse, AsyncAudioWithRawResponse
4-
from .speech import (
5-
Speech,
6-
AsyncSpeech,
7-
SpeechWithRawResponse,
8-
AsyncSpeechWithRawResponse,
9-
)
10-
from .translations import (
11-
Translations,
12-
AsyncTranslations,
13-
TranslationsWithRawResponse,
14-
AsyncTranslationsWithRawResponse,
15-
)
4+
from .speech import Speech, AsyncSpeech, SpeechWithRawResponse, AsyncSpeechWithRawResponse
5+
from .translations import Translations, AsyncTranslations, TranslationsWithRawResponse, AsyncTranslationsWithRawResponse
166
from .transcriptions import (
177
Transcriptions,
188
AsyncTranscriptions,

0 commit comments

Comments
 (0)