Skip to content

Commit 5290639

Browse files
chore(internal): reformat imports (#944)
1 parent 23fe7ee commit 5290639

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

+374
-410
lines changed

pyproject.toml

+18-19
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-
# 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",
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",
6161
"dirty-equals>=0.6.0",
6262
"azure-identity >=1.14.1",
6363
"types-tqdm > 4"
@@ -68,10 +68,12 @@ format = { chain = [
6868
"format:black",
6969
"format:docs",
7070
"format:ruff",
71+
"format:isort",
7172
]}
7273
"format:black" = "black ."
7374
"format:docs" = "python bin/blacken-docs.py README.md api.md"
7475
"format:ruff" = "ruff --fix ."
76+
"format:isort" = "isort ."
7577

7678
"check:ruff" = "ruff ."
7779

@@ -126,13 +128,16 @@ reportImplicitOverride = true
126128
reportImportCycles = false
127129
reportPrivateUsage = false
128130

131+
[tool.isort]
132+
profile = "black"
133+
length_sort = true
134+
extra_standard_library = ["typing_extensions"]
135+
129136
[tool.ruff]
130137
line-length = 120
131-
output-format = "grouped"
138+
format = "grouped"
132139
target-version = "py37"
133140
select = [
134-
# isort
135-
"I",
136141
# remove unused imports
137142
"F401",
138143
# bare except statements
@@ -150,12 +155,6 @@ unfixable = [
150155
]
151156
ignore-init-module-imports = true
152157

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"]
159158

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

requirements-dev.lock

+2-17
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,11 @@ annotated-types==0.6.0
1111
anyio==4.1.0
1212
argcomplete==3.1.2
1313
attrs==23.1.0
14-
azure-core==1.29.5
1514
azure-identity==1.15.0
1615
black==23.3.0
1716
certifi==2023.7.22
18-
cffi==1.16.0
19-
charset-normalizer==3.3.2
2017
click==8.1.7
2118
colorlog==6.7.0
22-
cryptography==41.0.7
2319
dirty-equals==0.6.0
2420
distlib==0.3.7
2521
distro==1.8.0
@@ -30,43 +26,32 @@ httpcore==1.0.2
3026
httpx==0.25.2
3127
idna==3.4
3228
iniconfig==2.0.0
33-
msal==1.26.0
34-
msal-extensions==1.0.0
29+
isort==5.10.1
3530
mypy==1.7.1
3631
mypy-extensions==1.0.0
3732
nodeenv==1.8.0
3833
nox==2023.4.22
39-
numpy==1.26.2
4034
packaging==23.2
41-
pandas==2.1.3
42-
pandas-stubs==2.1.1.230928
4335
pathspec==0.11.2
4436
platformdirs==3.11.0
4537
pluggy==1.3.0
46-
portalocker==2.8.2
4738
py==1.11.0
48-
pycparser==2.21
4939
pydantic==2.4.2
5040
pydantic-core==2.10.1
51-
pyjwt==2.8.0
5241
pyright==1.1.332
5342
pytest==7.1.1
5443
pytest-asyncio==0.21.1
5544
python-dateutil==2.8.2
5645
pytz==2023.3.post1
57-
requests==2.31.0
5846
respx==0.20.2
59-
ruff==0.1.7
47+
ruff==0.0.282
6048
six==1.16.0
6149
sniffio==1.3.0
6250
time-machine==2.9.0
6351
tomli==2.0.1
6452
tqdm==4.66.1
65-
types-pytz==2023.3.1.1
6653
types-tqdm==4.66.0.2
6754
typing-extensions==4.8.0
68-
tzdata==2023.3
69-
urllib3==2.1.0
7055
virtualenv==20.24.5
7156
# The following packages are considered to be unsafe in a requirements file:
7257
setuptools==68.2.2

src/openai/__init__.py

+25-16
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,17 @@
88
from . import types
99
from ._types import NoneType, Transport, ProxiesTypes
1010
from ._utils import file_from_path
11-
from ._client import Client, OpenAI, Stream, Timeout, Transport, AsyncClient, AsyncOpenAI, AsyncStream, RequestOptions
11+
from ._client import (
12+
Client,
13+
OpenAI,
14+
Stream,
15+
Timeout,
16+
Transport,
17+
AsyncClient,
18+
AsyncOpenAI,
19+
AsyncStream,
20+
RequestOptions,
21+
)
1222
from ._version import __title__, __version__
1323
from ._exceptions import (
1424
APIError,
@@ -62,7 +72,8 @@
6272

6373
from .lib import azure as _azure
6474
from .version import VERSION as VERSION
65-
from .lib.azure import AzureOpenAI as AzureOpenAI, AsyncAzureOpenAI as AsyncAzureOpenAI
75+
from .lib.azure import AzureOpenAI as AzureOpenAI
76+
from .lib.azure import AsyncAzureOpenAI as AsyncAzureOpenAI
6677
from .lib._old_api import *
6778

6879
_setup_logging()
@@ -319,17 +330,15 @@ def _reset_client() -> None: # type: ignore[reportUnusedFunction]
319330
_client = None
320331

321332

322-
from ._module_client import (
323-
beta as beta,
324-
chat as chat,
325-
audio as audio,
326-
edits as edits,
327-
files as files,
328-
images as images,
329-
models as models,
330-
embeddings as embeddings,
331-
fine_tunes as fine_tunes,
332-
completions as completions,
333-
fine_tuning as fine_tuning,
334-
moderations as moderations,
335-
)
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

src/openai/_client.py

+4-11
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,12 @@
2020
ProxiesTypes,
2121
RequestOptions,
2222
)
23-
from ._utils import (
24-
is_given,
25-
is_mapping,
26-
get_async_library,
27-
)
23+
from ._utils import is_given, is_mapping, get_async_library
2824
from ._version import __version__
29-
from ._streaming import Stream as Stream, AsyncStream as AsyncStream
25+
from ._streaming import Stream as Stream
26+
from ._streaming import AsyncStream as AsyncStream
3027
from ._exceptions import OpenAIError, APIStatusError
31-
from ._base_client import (
32-
DEFAULT_MAX_RETRIES,
33-
SyncAPIClient,
34-
AsyncAPIClient,
35-
)
28+
from ._base_client import DEFAULT_MAX_RETRIES, SyncAPIClient, AsyncAPIClient
3629

3730
__all__ = [
3831
"Timeout",

src/openai/_compat.py

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

4444
else:
4545
if PYDANTIC_V2:
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
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
5453
else:
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
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
6361

6462

6563
# refactored config

src/openai/_extras/__init__.py

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

src/openai/_models.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,17 @@
3030
AnyMapping,
3131
HttpxRequestFiles,
3232
)
33-
from ._utils import is_list, is_given, is_mapping, parse_date, parse_datetime, strip_not_given
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
3443
from ._compat import (
35-
PYDANTIC_V2,
36-
ConfigDict,
37-
GenericModel as BaseGenericModel,
3844
get_args,
3945
is_union,
4046
parse_obj,

src/openai/_types.py

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

2431
import pydantic
2532
from httpx import URL, Proxy, Timeout, Response, BaseTransport, AsyncBaseTransport

src/openai/_utils/__init__.py

+36-40
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,37 @@
11
from ._proxy import LazyProxy as LazyProxy
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-
)
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

src/openai/_utils/_utils.py

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

2323
from .._types import Headers, NotGiven, FileTypes, NotGivenOr, HeadersLike
24-
from .._compat import is_union as _is_union, parse_date as parse_date, parse_datetime as parse_datetime
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
2527

2628
_T = TypeVar("_T")
2729
_TupleT = TypeVar("_TupleT", bound=Tuple[object, ...])

0 commit comments

Comments
 (0)