openai/openai-python

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
6afde0dc8512a16ff2eca781fee0395cab254f8c

Branches

Tags

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

Clone

HTTPS

Download ZIP

pyproject.toml

225lines · modecode

1[project]
2name = "openai"
3version = "1.61.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 "tqdm > 4",
18 "jiter>=0.4.0, <1",
19]
20requires-python = ">= 3.8"
21classifiers = [
22 "Typing :: Typed",
23 "Intended Audience :: Developers",
24 "Programming Language :: Python :: 3.8",
25 "Programming Language :: Python :: 3.9",
26 "Programming Language :: Python :: 3.10",
27 "Programming Language :: Python :: 3.11",
28 "Programming Language :: Python :: 3.12",
29 "Operating System :: OS Independent",
30 "Operating System :: POSIX",
31 "Operating System :: MacOS",
32 "Operating System :: POSIX :: Linux",
33 "Operating System :: Microsoft :: Windows",
34 "Topic :: Software Development :: Libraries :: Python Modules",
35 "License :: OSI Approved :: Apache Software License"
36]
37
38[project.urls]
39Homepage = "https://github.com/openai/openai-python"
40Repository = "https://github.com/openai/openai-python"
41
42[project.scripts]
43openai = "openai.cli:main"
44
45[project.optional-dependencies]
46realtime = ["websockets >= 13, < 15"]
47datalib = ["numpy >= 1", "pandas >= 1.2.3", "pandas-stubs >= 1.1.0.11"]
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[tool.rye.scripts]
73format = { chain = [
74 "format:ruff",
75 "format:docs",
76 "fix:ruff",
77 # run formatting again to fix any inconsistencies when imports are stripped
78 "format:ruff",
79]}
80"format:docs" = "python scripts/utils/ruffen-docs.py README.md api.md"
81"format:ruff" = "ruff format"
82
83"lint" = { chain = [
84 "check:ruff",
85 "typecheck",
86 "check:importable",
87]}
88"check:ruff" = "ruff check ."
89"fix:ruff" = "ruff check --fix ."
90
91"check:importable" = "python -c 'import openai'"
92
93typecheck = { chain = [
94 "typecheck:pyright",
95 "typecheck:mypy"
96]}
97"typecheck:pyright" = "pyright"
98"typecheck:verify-types" = "pyright --verifytypes openai --ignoreexternal"
99"typecheck:mypy" = "mypy ."
100
101[build-system]
102requires = ["hatchling", "hatch-fancy-pypi-readme"]
103build-backend = "hatchling.build"
104
105[tool.hatch.build]
106include = [
107 "src/*"
108]
109
110[tool.hatch.build.targets.wheel]
111packages = ["src/openai"]
112
113[tool.hatch.build.targets.sdist]
114# Basically everything except hidden files/directories (such as .github, .devcontainers, .python-version, etc)
115include = [
116 "/*.toml",
117 "/*.json",
118 "/*.lock",
119 "/*.md",
120 "/mypy.ini",
121 "/noxfile.py",
122 "bin/*",
123 "examples/*",
124 "src/*",
125 "tests/*",
126]
127
128[tool.hatch.metadata.hooks.fancy-pypi-readme]
129content-type = "text/markdown"
130
131[[tool.hatch.metadata.hooks.fancy-pypi-readme.fragments]]
132path = "README.md"
133
134[[tool.hatch.metadata.hooks.fancy-pypi-readme.substitutions]]
135# replace relative links with absolute links
136pattern = '\[(.+?)\]\(((?!https?://)\S+?)\)'
137replacement = '[\1](https://github.com/openai/openai-python/tree/main/\g<2>)'
138
139[tool.pytest.ini_options]
140testpaths = ["tests"]
141addopts = "--tb=short"
142xfail_strict = true
143asyncio_mode = "auto"
144asyncio_default_fixture_loop_scope = "session"
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 # uses inline `uv` script dependencies
162 # which means it can't be type checked
163 "examples/realtime/audio_util.py",
164 "examples/realtime/push_to_talk_app.py"
165]
166
167reportImplicitOverride = true
168
169reportImportCycles = false
170reportPrivateUsage = false
171
172
173[tool.ruff]
174line-length = 120
175output-format = "grouped"
176target-version = "py37"
177
178[tool.ruff.format]
179docstring-code-format = true
180
181[tool.ruff.lint]
182select = [
183 # isort
184 "I",
185 # bugbear rules
186 "B",
187 # remove unused imports
188 "F401",
189 # bare except statements
190 "E722",
191 # unused arguments
192 "ARG",
193 # print statements
194 "T201",
195 "T203",
196 # misuse of typing.TYPE_CHECKING
197 "TC004",
198 # import rules
199 "TID251",
200]
201ignore = [
202 # mutable defaults
203 "B006",
204]
205unfixable = [
206 # disable auto fix for print statements
207 "T201",
208 "T203",
209]
210
211[tool.ruff.lint.flake8-tidy-imports.banned-api]
212"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"
213
214[tool.ruff.lint.isort]
215length-sort = true
216length-sort-straight = true
217combine-as-imports = true
218extra-standard-library = ["typing_extensions"]
219known-first-party = ["openai", "tests"]
220
221[tool.ruff.lint.per-file-ignores]
222"bin/**.py" = ["T201", "T203"]
223"scripts/**.py" = ["T201", "T203"]
224"tests/**.py" = ["T201", "T203"]
225"examples/**.py" = ["T201", "T203"]
226