openai/openai-python

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
47a3ef485e8d759ac02495f40fbb5eed47bbbc3d

Branches

Tags

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

Clone

HTTPS

Download ZIP

pyproject.toml

209lines · modecode

1[project]
2name = "openai"
3version = "1.77.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.399",
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
152reportOverlappingOverload = false
153
154reportImportCycles = false
155reportPrivateUsage = false
156
157[tool.ruff]
158line-length = 120
159output-format = "grouped"
160target-version = "py37"
161
162[tool.ruff.format]
163docstring-code-format = true
164
165[tool.ruff.lint]
166select = [
167 # isort
168 "I",
169 # bugbear rules
170 "B",
171 # remove unused imports
172 "F401",
173 # bare except statements
174 "E722",
175 # unused arguments
176 "ARG",
177 # print statements
178 "T201",
179 "T203",
180 # misuse of typing.TYPE_CHECKING
181 "TC004",
182 # import rules
183 "TID251",
184]
185ignore = [
186 # mutable defaults
187 "B006",
188]
189unfixable = [
190 # disable auto fix for print statements
191 "T201",
192 "T203",
193]
194
195[tool.ruff.lint.flake8-tidy-imports.banned-api]
196"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"
197
198[tool.ruff.lint.isort]
199length-sort = true
200length-sort-straight = true
201combine-as-imports = true
202extra-standard-library = ["typing_extensions"]
203known-first-party = ["openai", "tests"]
204
205[tool.ruff.lint.per-file-ignores]
206"bin/**.py" = ["T201", "T203"]
207"scripts/**.py" = ["T201", "T203"]
208"tests/**.py" = ["T201", "T203"]
209"examples/**.py" = ["T201", "T203"]