openai/openai-python

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
33e40854beef0cb18c0790bea953678c30b6fb5c

Branches

Tags

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

Clone

HTTPS

Download ZIP

pyproject.toml

224lines · modecode

1[project]
2name = "openai"
3version = "1.59.6"
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"
144filterwarnings = [
145 "error"
146]
147
148[tool.pyright]
149# this enables practically every flag given by pyright.
150# there are a couple of flags that are still disabled by
151# default in strict mode as they are experimental and niche.
152typeCheckingMode = "strict"
153pythonVersion = "3.8"
154
155exclude = [
156 "_dev",
157 ".venv",
158 ".nox",
159
160 # uses inline `uv` script dependencies
161 # which means it can't be type checked
162 "examples/realtime/audio_util.py",
163 "examples/realtime/push_to_talk_app.py"
164]
165
166reportImplicitOverride = true
167
168reportImportCycles = false
169reportPrivateUsage = false
170
171
172[tool.ruff]
173line-length = 120
174output-format = "grouped"
175target-version = "py37"
176
177[tool.ruff.format]
178docstring-code-format = true
179
180[tool.ruff.lint]
181select = [
182 # isort
183 "I",
184 # bugbear rules
185 "B",
186 # remove unused imports
187 "F401",
188 # bare except statements
189 "E722",
190 # unused arguments
191 "ARG",
192 # print statements
193 "T201",
194 "T203",
195 # misuse of typing.TYPE_CHECKING
196 "TCH004",
197 # import rules
198 "TID251",
199]
200ignore = [
201 # mutable defaults
202 "B006",
203]
204unfixable = [
205 # disable auto fix for print statements
206 "T201",
207 "T203",
208]
209
210[tool.ruff.lint.flake8-tidy-imports.banned-api]
211"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"
212
213[tool.ruff.lint.isort]
214length-sort = true
215length-sort-straight = true
216combine-as-imports = true
217extra-standard-library = ["typing_extensions"]
218known-first-party = ["openai", "tests"]
219
220[tool.ruff.lint.per-file-ignores]
221"bin/**.py" = ["T201", "T203"]
222"scripts/**.py" = ["T201", "T203"]
223"tests/**.py" = ["T201", "T203"]
224"examples/**.py" = ["T201", "T203"]
225