openai/openai-python

Public

mirrored from https://github.com/openai/openai-pythonAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
83091e96cf43f344d22799c22eea301aeae36d51

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

pyproject.toml

220lines · modecode

1[project]
2name = "openai"
3version = "1.55.0"
4description = "The official Python library for the openai API"
5dynamic = ["readme"]
6license = "Apache-2.0"
7authors = [
8{ name = "OpenAI", email = "support@openai.com" },
9]
10dependencies = [
11 "httpx>=0.23.0, <1",
12 "pydantic>=1.9.0, <3",
13 "typing-extensions>=4.11, <5",
14 "anyio>=3.5.0, <5",
15 "distro>=1.7.0, <2",
16 "sniffio",
17 "cached-property; python_version < '3.8'",
18 "tqdm > 4",
19 "jiter>=0.4.0, <1",
20]
21requires-python = ">= 3.8"
22classifiers = [
23 "Typing :: Typed",
24 "Intended Audience :: Developers",
25 "Programming Language :: Python :: 3.8",
26 "Programming Language :: Python :: 3.9",
27 "Programming Language :: Python :: 3.10",
28 "Programming Language :: Python :: 3.11",
29 "Programming Language :: Python :: 3.12",
30 "Operating System :: OS Independent",
31 "Operating System :: POSIX",
32 "Operating System :: MacOS",
33 "Operating System :: POSIX :: Linux",
34 "Operating System :: Microsoft :: Windows",
35 "Topic :: Software Development :: Libraries :: Python Modules",
36 "License :: OSI Approved :: Apache Software License"
37]
38
39[project.optional-dependencies]
40datalib = ["numpy >= 1", "pandas >= 1.2.3", "pandas-stubs >= 1.1.0.11"]
41
42[project.urls]
43Homepage = "https://github.com/openai/openai-python"
44Repository = "https://github.com/openai/openai-python"
45
46[project.scripts]
47openai = "openai.cli:main"
48
49[tool.rye]
50managed = true
51# version pins are in requirements-dev.lock
52dev-dependencies = [
53 "pyright>=1.1.359",
54 "mypy",
55 "respx",
56 "pytest",
57 "pytest-asyncio",
58 "ruff",
59 "time-machine",
60 "nox",
61 "dirty-equals>=0.6.0",
62 "importlib-metadata>=6.7.0",
63 "rich>=13.7.1",
64 "inline-snapshot >=0.7.0",
65 "azure-identity >=1.14.1",
66 "types-tqdm > 4",
67 "types-pyaudio > 0",
68 "trio >=0.22.2",
69 "nest_asyncio==1.6.0"
70
71]
72
73[tool.rye.scripts]
74format = { chain = [
75 "format:ruff",
76 "format:docs",
77 "fix:ruff",
78 # run formatting again to fix any inconsistencies when imports are stripped
79 "format:ruff",
80]}
81"format:docs" = "python scripts/utils/ruffen-docs.py README.md api.md"
82"format:ruff" = "ruff format"
83
84"lint" = { chain = [
85 "check:ruff",
86 "typecheck",
87 "check:importable",
88]}
89"check:ruff" = "ruff check ."
90"fix:ruff" = "ruff check --fix ."
91
92"check:importable" = "python -c 'import openai'"
93
94typecheck = { chain = [
95 "typecheck:pyright",
96 "typecheck:mypy"
97]}
98"typecheck:pyright" = "pyright"
99"typecheck:verify-types" = "pyright --verifytypes openai --ignoreexternal"
100"typecheck:mypy" = "mypy ."
101
102[build-system]
103requires = ["hatchling", "hatch-fancy-pypi-readme"]
104build-backend = "hatchling.build"
105
106[tool.hatch.build]
107include = [
108 "src/*"
109]
110
111[tool.hatch.build.targets.wheel]
112packages = ["src/openai"]
113
114[tool.hatch.build.targets.sdist]
115# Basically everything except hidden files/directories (such as .github, .devcontainers, .python-version, etc)
116include = [
117 "/*.toml",
118 "/*.json",
119 "/*.lock",
120 "/*.md",
121 "/mypy.ini",
122 "/noxfile.py",
123 "bin/*",
124 "examples/*",
125 "src/*",
126 "tests/*",
127]
128
129[tool.hatch.metadata.hooks.fancy-pypi-readme]
130content-type = "text/markdown"
131
132[[tool.hatch.metadata.hooks.fancy-pypi-readme.fragments]]
133path = "README.md"
134
135[[tool.hatch.metadata.hooks.fancy-pypi-readme.substitutions]]
136# replace relative links with absolute links
137pattern = '\[(.+?)\]\(((?!https?://)\S+?)\)'
138replacement = '[\1](https://github.com/openai/openai-python/tree/main/\g<2>)'
139
140[tool.pytest.ini_options]
141testpaths = ["tests"]
142addopts = "--tb=short"
143xfail_strict = true
144asyncio_mode = "auto"
145filterwarnings = [
146 "error"
147]
148
149[tool.pyright]
150# this enables practically every flag given by pyright.
151# there are a couple of flags that are still disabled by
152# default in strict mode as they are experimental and niche.
153typeCheckingMode = "strict"
154pythonVersion = "3.8"
155
156exclude = [
157 "_dev",
158 ".venv",
159 ".nox",
160]
161
162reportImplicitOverride = true
163
164reportImportCycles = false
165reportPrivateUsage = false
166
167
168[tool.ruff]
169line-length = 120
170output-format = "grouped"
171target-version = "py37"
172
173[tool.ruff.format]
174docstring-code-format = true
175
176[tool.ruff.lint]
177select = [
178 # isort
179 "I",
180 # bugbear rules
181 "B",
182 # remove unused imports
183 "F401",
184 # bare except statements
185 "E722",
186 # unused arguments
187 "ARG",
188 # print statements
189 "T201",
190 "T203",
191 # misuse of typing.TYPE_CHECKING
192 "TCH004",
193 # import rules
194 "TID251",
195]
196ignore = [
197 # mutable defaults
198 "B006",
199]
200unfixable = [
201 # disable auto fix for print statements
202 "T201",
203 "T203",
204]
205
206[tool.ruff.lint.flake8-tidy-imports.banned-api]
207"functools.lru_cache".msg = "This function does not retain type information for the wrapped function's arguments; The `lru_cache` function from `_utils` should be used instead"
208
209[tool.ruff.lint.isort]
210length-sort = true
211length-sort-straight = true
212combine-as-imports = true
213extra-standard-library = ["typing_extensions"]
214known-first-party = ["openai", "tests"]
215
216[tool.ruff.lint.per-file-ignores]
217"bin/**.py" = ["T201", "T203"]
218"scripts/**.py" = ["T201", "T203"]
219"tests/**.py" = ["T201", "T203"]
220"examples/**.py" = ["T201", "T203"]
221