openai/openai-python
Publicmirrored from https://github.com/openai/openai-pythonAvailable
pyproject.toml
271lines · modecode
| 1 | [project] |
| 2 | name = "openai" |
| 3 | version = "2.41.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 | |
| 11 | dependencies = [ |
| 12 | "httpx>=0.23.0, <1", |
| 13 | "pydantic>=1.9.0, <3", |
| 14 | "typing-extensions>=4.14, <5", |
| 15 | "anyio>=3.5.0, <5", |
| 16 | "distro>=1.7.0, <2", |
| 17 | "sniffio", |
| 18 | ] |
| 19 | |
| 20 | requires-python = ">= 3.9" |
| 21 | classifiers = [ |
| 22 | "Typing :: Typed", |
| 23 | "Intended Audience :: Developers", |
| 24 | "Programming Language :: Python :: 3.9", |
| 25 | "Programming Language :: Python :: 3.10", |
| 26 | "Programming Language :: Python :: 3.11", |
| 27 | "Programming Language :: Python :: 3.12", |
| 28 | "Programming Language :: Python :: 3.13", |
| 29 | "Programming Language :: Python :: 3.14", |
| 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.urls] |
| 40 | Homepage = "https://github.com/openai/openai-python" |
| 41 | Repository = "https://github.com/openai/openai-python" |
| 42 | |
| 43 | [project.optional-dependencies] |
| 44 | aiohttp = ["aiohttp", "httpx_aiohttp>=0.1.9"] |
| 45 | realtime = ["websockets >= 13, < 16"] |
| 46 | |
| 47 | [tool.rye] |
| 48 | managed = true |
| 49 | # version pins are in requirements-dev.lock |
| 50 | dev-dependencies = [ |
| 51 | "pyright==1.1.399", |
| 52 | "mypy==1.17", |
| 53 | "respx", |
| 54 | "pytest", |
| 55 | "pytest-asyncio", |
| 56 | "ruff", |
| 57 | "time-machine", |
| 58 | "nox", |
| 59 | "dirty-equals>=0.6.0", |
| 60 | "importlib-metadata>=6.7.0", |
| 61 | "rich>=13.7.1", |
| 62 | "pytest-xdist>=3.6.1", |
| 63 | "griffe>=1", |
| 64 | ] |
| 65 | |
| 66 | [tool.rye.scripts] |
| 67 | format = { chain = [ |
| 68 | "format:ruff", |
| 69 | "format:docs", |
| 70 | "fix:ruff", |
| 71 | # run formatting again to fix any inconsistencies when imports are stripped |
| 72 | "format:ruff", |
| 73 | ]} |
| 74 | "format:docs" = "bash -c 'python scripts/utils/ruffen-docs.py README.md $(find . -type f -name api.md)'" |
| 75 | "format:ruff" = "ruff format" |
| 76 | |
| 77 | "lint" = { chain = [ |
| 78 | "check:ruff", |
| 79 | "typecheck", |
| 80 | "check:importable", |
| 81 | ]} |
| 82 | "check:ruff" = "ruff check ." |
| 83 | "fix:ruff" = "ruff check --fix ." |
| 84 | |
| 85 | "check:importable" = "python -c 'import openai'" |
| 86 | |
| 87 | typecheck = { chain = [ |
| 88 | "typecheck:pyright", |
| 89 | "typecheck:mypy" |
| 90 | ]} |
| 91 | "typecheck:pyright" = "pyright" |
| 92 | "typecheck:verify-types" = "pyright --verifytypes openai --ignoreexternal" |
| 93 | "typecheck:mypy" = "mypy ." |
| 94 | |
| 95 | [build-system] |
| 96 | requires = ["hatchling==1.26.3", "hatch-fancy-pypi-readme"] |
| 97 | build-backend = "hatchling.build" |
| 98 | |
| 99 | [tool.hatch.build] |
| 100 | include = [ |
| 101 | "src/*" |
| 102 | ] |
| 103 | |
| 104 | [tool.hatch.build.targets.wheel] |
| 105 | packages = ["src/openai"] |
| 106 | |
| 107 | [tool.hatch.build.targets.sdist] |
| 108 | # Basically everything except hidden files/directories (such as .github, .devcontainers, .python-version, etc) |
| 109 | include = [ |
| 110 | "/*.toml", |
| 111 | "/*.json", |
| 112 | "/*.lock", |
| 113 | "/*.md", |
| 114 | "/mypy.ini", |
| 115 | "/noxfile.py", |
| 116 | "bin/*", |
| 117 | "examples/*", |
| 118 | "src/*", |
| 119 | "tests/*", |
| 120 | ] |
| 121 | |
| 122 | [tool.hatch.metadata.hooks.fancy-pypi-readme] |
| 123 | content-type = "text/markdown" |
| 124 | |
| 125 | [[tool.hatch.metadata.hooks.fancy-pypi-readme.fragments]] |
| 126 | path = "README.md" |
| 127 | |
| 128 | [[tool.hatch.metadata.hooks.fancy-pypi-readme.substitutions]] |
| 129 | # replace relative links with absolute links |
| 130 | pattern = '\[(.+?)\]\(((?!https?://)\S+?)\)' |
| 131 | replacement = '[\1](https://github.com/openai/openai-python/tree/main/\g<2>)' |
| 132 | |
| 133 | [tool.pytest.ini_options] |
| 134 | testpaths = ["tests"] |
| 135 | addopts = "--tb=short -n auto" |
| 136 | xfail_strict = true |
| 137 | asyncio_mode = "auto" |
| 138 | asyncio_default_fixture_loop_scope = "session" |
| 139 | filterwarnings = [ |
| 140 | "error" |
| 141 | ] |
| 142 | |
| 143 | [tool.pyright] |
| 144 | # this enables practically every flag given by pyright. |
| 145 | # there are a couple of flags that are still disabled by |
| 146 | # default in strict mode as they are experimental and niche. |
| 147 | typeCheckingMode = "strict" |
| 148 | pythonVersion = "3.9" |
| 149 | |
| 150 | exclude = [ |
| 151 | "_dev", |
| 152 | ".venv", |
| 153 | ".nox", |
| 154 | ".git", |
| 155 | ] |
| 156 | |
| 157 | reportImplicitOverride = true |
| 158 | reportOverlappingOverload = false |
| 159 | |
| 160 | reportImportCycles = false |
| 161 | reportPrivateUsage = false |
| 162 | |
| 163 | [tool.mypy] |
| 164 | pretty = true |
| 165 | show_error_codes = true |
| 166 | |
| 167 | # Exclude _files.py because mypy isn't smart enough to apply |
| 168 | # the correct type narrowing and as this is an internal module |
| 169 | # it's fine to just use Pyright. |
| 170 | # |
| 171 | # We also exclude our `tests` as mypy doesn't always infer |
| 172 | # types correctly and Pyright will still catch any type errors. |
| 173 | exclude = ["src/openai/_files.py", "_dev/.*.py", "tests/.*"] |
| 174 | |
| 175 | strict_equality = true |
| 176 | implicit_reexport = true |
| 177 | check_untyped_defs = true |
| 178 | no_implicit_optional = true |
| 179 | |
| 180 | warn_return_any = true |
| 181 | warn_unreachable = true |
| 182 | warn_unused_configs = true |
| 183 | |
| 184 | # Turn these options off as it could cause conflicts |
| 185 | # with the Pyright options. |
| 186 | warn_unused_ignores = false |
| 187 | warn_redundant_casts = false |
| 188 | |
| 189 | disallow_any_generics = true |
| 190 | disallow_untyped_defs = true |
| 191 | disallow_untyped_calls = true |
| 192 | disallow_subclassing_any = true |
| 193 | disallow_incomplete_defs = true |
| 194 | disallow_untyped_decorators = true |
| 195 | cache_fine_grained = true |
| 196 | |
| 197 | # By default, mypy reports an error if you assign a value to the result |
| 198 | # of a function call that doesn't return anything. We do this in our test |
| 199 | # cases: |
| 200 | # ``` |
| 201 | # result = ... |
| 202 | # assert result is None |
| 203 | # ``` |
| 204 | # Changing this codegen to make mypy happy would increase complexity |
| 205 | # and would not be worth it. |
| 206 | disable_error_code = "func-returns-value,overload-cannot-match" |
| 207 | |
| 208 | # https://github.com/python/mypy/issues/12162 |
| 209 | [[tool.mypy.overrides]] |
| 210 | module = "black.files.*" |
| 211 | ignore_errors = true |
| 212 | ignore_missing_imports = true |
| 213 | |
| 214 | |
| 215 | [tool.ruff] |
| 216 | line-length = 120 |
| 217 | output-format = "grouped" |
| 218 | target-version = "py38" |
| 219 | |
| 220 | [tool.ruff.format] |
| 221 | docstring-code-format = true |
| 222 | |
| 223 | [tool.ruff.lint] |
| 224 | select = [ |
| 225 | # isort |
| 226 | "I", |
| 227 | # bugbear rules |
| 228 | "B", |
| 229 | # remove unused imports |
| 230 | "F401", |
| 231 | # check for missing future annotations |
| 232 | "FA102", |
| 233 | # bare except statements |
| 234 | "E722", |
| 235 | # unused arguments |
| 236 | "ARG", |
| 237 | # print statements |
| 238 | "T201", |
| 239 | "T203", |
| 240 | # misuse of typing.TYPE_CHECKING |
| 241 | "TC004", |
| 242 | # import rules |
| 243 | "TID251", |
| 244 | ] |
| 245 | ignore = [ |
| 246 | # mutable defaults |
| 247 | "B006", |
| 248 | ] |
| 249 | unfixable = [ |
| 250 | # disable auto fix for print statements |
| 251 | "T201", |
| 252 | "T203", |
| 253 | ] |
| 254 | |
| 255 | extend-safe-fixes = ["FA102"] |
| 256 | |
| 257 | [tool.ruff.lint.flake8-tidy-imports.banned-api] |
| 258 | "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" |
| 259 | |
| 260 | [tool.ruff.lint.isort] |
| 261 | length-sort = true |
| 262 | length-sort-straight = true |
| 263 | combine-as-imports = true |
| 264 | extra-standard-library = ["typing_extensions"] |
| 265 | known-first-party = ["openai", "tests"] |
| 266 | |
| 267 | [tool.ruff.lint.per-file-ignores] |
| 268 | "bin/**.py" = ["T201", "T203"] |
| 269 | "scripts/**.py" = ["T201", "T203"] |
| 270 | "tests/**.py" = ["T201", "T203"] |
| 271 | "examples/**.py" = ["T201", "T203"] |
| 272 | |