openai/openai-python
Publicmirrored from https://github.com/openai/openai-pythonAvailable
pyproject.toml
220lines · modecode
| 1 | [project] |
| 2 | name = "openai" |
| 3 | version = "1.55.0" |
| 4 | description = "The official Python library for the openai API" |
| 5 | dynamic = ["readme"] |
| 6 | license = "Apache-2.0" |
| 7 | authors = [ |
| 8 | { name = "OpenAI", email = "support@openai.com" }, |
| 9 | ] |
| 10 | dependencies = [ |
| 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 | ] |
| 21 | requires-python = ">= 3.8" |
| 22 | classifiers = [ |
| 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] |
| 40 | datalib = ["numpy >= 1", "pandas >= 1.2.3", "pandas-stubs >= 1.1.0.11"] |
| 41 | |
| 42 | [project.urls] |
| 43 | Homepage = "https://github.com/openai/openai-python" |
| 44 | Repository = "https://github.com/openai/openai-python" |
| 45 | |
| 46 | [project.scripts] |
| 47 | openai = "openai.cli:main" |
| 48 | |
| 49 | [tool.rye] |
| 50 | managed = true |
| 51 | # version pins are in requirements-dev.lock |
| 52 | dev-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] |
| 74 | format = { 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 | |
| 94 | typecheck = { 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] |
| 103 | requires = ["hatchling", "hatch-fancy-pypi-readme"] |
| 104 | build-backend = "hatchling.build" |
| 105 | |
| 106 | [tool.hatch.build] |
| 107 | include = [ |
| 108 | "src/*" |
| 109 | ] |
| 110 | |
| 111 | [tool.hatch.build.targets.wheel] |
| 112 | packages = ["src/openai"] |
| 113 | |
| 114 | [tool.hatch.build.targets.sdist] |
| 115 | # Basically everything except hidden files/directories (such as .github, .devcontainers, .python-version, etc) |
| 116 | include = [ |
| 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] |
| 130 | content-type = "text/markdown" |
| 131 | |
| 132 | [[tool.hatch.metadata.hooks.fancy-pypi-readme.fragments]] |
| 133 | path = "README.md" |
| 134 | |
| 135 | [[tool.hatch.metadata.hooks.fancy-pypi-readme.substitutions]] |
| 136 | # replace relative links with absolute links |
| 137 | pattern = '\[(.+?)\]\(((?!https?://)\S+?)\)' |
| 138 | replacement = '[\1](https://github.com/openai/openai-python/tree/main/\g<2>)' |
| 139 | |
| 140 | [tool.pytest.ini_options] |
| 141 | testpaths = ["tests"] |
| 142 | addopts = "--tb=short" |
| 143 | xfail_strict = true |
| 144 | asyncio_mode = "auto" |
| 145 | filterwarnings = [ |
| 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. |
| 153 | typeCheckingMode = "strict" |
| 154 | pythonVersion = "3.8" |
| 155 | |
| 156 | exclude = [ |
| 157 | "_dev", |
| 158 | ".venv", |
| 159 | ".nox", |
| 160 | ] |
| 161 | |
| 162 | reportImplicitOverride = true |
| 163 | |
| 164 | reportImportCycles = false |
| 165 | reportPrivateUsage = false |
| 166 | |
| 167 | |
| 168 | [tool.ruff] |
| 169 | line-length = 120 |
| 170 | output-format = "grouped" |
| 171 | target-version = "py37" |
| 172 | |
| 173 | [tool.ruff.format] |
| 174 | docstring-code-format = true |
| 175 | |
| 176 | [tool.ruff.lint] |
| 177 | select = [ |
| 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 | ] |
| 196 | ignore = [ |
| 197 | # mutable defaults |
| 198 | "B006", |
| 199 | ] |
| 200 | unfixable = [ |
| 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] |
| 210 | length-sort = true |
| 211 | length-sort-straight = true |
| 212 | combine-as-imports = true |
| 213 | extra-standard-library = ["typing_extensions"] |
| 214 | known-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 | |