openai/openai-python

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
de9532c19b6abb360608479997795f3aeb570b45

Branches

Tags

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

Clone

HTTPS

Download ZIP

pyproject.toml

208lines · modecode

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