| 1 |
[build-system] |
| 2 |
# setuptools v77 adds PEP 639 support |
| 3 |
requires = ["setuptools >= 77"] |
| 4 |
build-backend = "setuptools.build_meta" |
| 5 |
|
| 6 |
[project] |
| 7 |
name = "trio" |
| 8 |
description = "A friendly Python library for async concurrency and I/O" |
| 9 |
authors = [{name = "Nathaniel J. Smith", email = "[email protected]"}] |
| 10 |
license = "MIT OR Apache-2.0" |
| 11 |
license-files = ["LICENSE*"] |
| 12 |
keywords = [ |
| 13 |
"async", |
| 14 |
"io", |
| 15 |
"networking", |
| 16 |
"trio", |
| 17 |
] |
| 18 |
classifiers = [ |
| 19 |
"Development Status :: 4 - Beta", |
| 20 |
"Framework :: Trio", |
| 21 |
"Intended Audience :: Developers", |
| 22 |
"Operating System :: POSIX :: Linux", |
| 23 |
"Operating System :: MacOS :: MacOS X", |
| 24 |
"Operating System :: POSIX :: BSD", |
| 25 |
"Operating System :: Microsoft :: Windows", |
| 26 |
"Programming Language :: Python :: Implementation :: CPython", |
| 27 |
"Programming Language :: Python :: Implementation :: PyPy", |
| 28 |
"Programming Language :: Python :: 3 :: Only", |
| 29 |
"Programming Language :: Python :: 3.10", |
| 30 |
"Programming Language :: Python :: 3.11", |
| 31 |
"Programming Language :: Python :: 3.12", |
| 32 |
"Programming Language :: Python :: 3.13", |
| 33 |
"Programming Language :: Python :: 3.14", |
| 34 |
"Topic :: System :: Networking", |
| 35 |
"Typing :: Typed", |
| 36 |
] |
| 37 |
requires-python = ">=3.10" |
| 38 |
dependencies = [ |
| 39 |
# attrs 19.2.0 adds `eq` option to decorators |
| 40 |
# attrs 20.1.0 adds @frozen |
| 41 |
# attrs 21.1.0 adds a dataclass transform for type-checkers |
| 42 |
# attrs 21.3.0 adds `import attrs` |
| 43 |
"attrs >= 23.2.0", |
| 44 |
"sortedcontainers", |
| 45 |
"idna", |
| 46 |
"outcome", |
| 47 |
"sniffio >= 1.3.0", |
| 48 |
# cffi 1.12 adds from_buffer(require_writable=True) and ffi.release() |
| 49 |
# cffi 1.14 fixes memory leak inside ffi.getwinerror() |
| 50 |
# cffi is required on Windows, except on PyPy where it is built-in |
| 51 |
"cffi>=1.14; os_name == 'nt' and implementation_name != 'pypy'", |
| 52 |
"exceptiongroup; python_version < '3.11'", |
| 53 |
] |
| 54 |
dynamic = ["version"] |
| 55 |
|
| 56 |
[project.readme] |
| 57 |
file = "README.rst" |
| 58 |
content-type = "text/x-rst" |
| 59 |
|
| 60 |
[project.urls] |
| 61 |
Homepage = "https://github.com/python-trio/trio" |
| 62 |
Documentation = "https://trio.readthedocs.io/" |
| 63 |
Changelog = "https://trio.readthedocs.io/en/latest/history.html" |
| 64 |
|
| 65 |
[project.entry-points.hypothesis] |
| 66 |
trio = "trio._core._run:_hypothesis_plugin_setup" |
| 67 |
|
| 68 |
[tool.setuptools] |
| 69 |
# This means, just install *everything* you see under trio/, even if it |
| 70 |
# doesn't look like a source file, so long as it appears in MANIFEST.in: |
| 71 |
include-package-data = true |
| 72 |
|
| 73 |
[tool.setuptools.dynamic] |
| 74 |
version = {attr = "trio._version.__version__"} |
| 75 |
|
| 76 |
[tool.black] |
| 77 |
force-exclude = ''' |
| 78 |
( |
| 79 |
^/docs/source/reference-.* |
| 80 |
| ^/docs/source/tutorial |
| 81 |
| ^/src/trio/_core/_generated_windows_ffi.py |
| 82 |
) |
| 83 |
''' |
| 84 |
|
| 85 |
[tool.codespell] |
| 86 |
ignore-words-list = 'astroid,crasher,asend' |
| 87 |
|
| 88 |
[tool.typos] |
| 89 |
default.extend-ignore-re = [ |
| 90 |
"(?Rm)^.*(#|//)\\s*spellchecker:disable-line$", |
| 91 |
] |
| 92 |
|
| 93 |
[tool.typos.default.extend-identifiers] |
| 94 |
IPPROTO_ND = "IPPROTO_ND" |
| 95 |
|
| 96 |
[tool.typos.default.extend-words] |
| 97 |
astroid = "astroid" |
| 98 |
crasher = "crasher" |
| 99 |
asend = "asend" |
| 100 |
|
| 101 |
[tool.ruff] |
| 102 |
respect-gitignore = true |
| 103 |
fix = true |
| 104 |
|
| 105 |
# The directories to consider when resolving first vs. third-party imports. |
| 106 |
# Does not control what files to include/exclude! |
| 107 |
src = ["src/trio"] |
| 108 |
|
| 109 |
include = ["*.py", "*.pyi", "**/pyproject.toml"] |
| 110 |
|
| 111 |
extend-exclude = [ |
| 112 |
"docs/source/reference-*", |
| 113 |
"docs/source/tutorial/*", |
| 114 |
"src/trio/_core/_generated_windows_ffi.py" |
| 115 |
] |
| 116 |
|
| 117 |
[tool.ruff.lint] |
| 118 |
preview = true |
| 119 |
allowed-confusables = ["–"] |
| 120 |
|
| 121 |
select = [ |
| 122 |
"A", # flake8-builtins |
| 123 |
"ANN", # flake8-annotations |
| 124 |
"ASYNC", # flake8-async |
| 125 |
"B", # flake8-bugbear |
| 126 |
"C4", # flake8-comprehensions |
| 127 |
"COM", # flake8-commas |
| 128 |
"E", # Error |
| 129 |
"EXE", # flake8-executable |
| 130 |
"F", # pyflakes |
| 131 |
"FA", # flake8-future-annotations |
| 132 |
"FLY", # flynt |
| 133 |
"FURB", # refurb |
| 134 |
"I", # isort |
| 135 |
"ICN", # flake8-import-conventions |
| 136 |
"PERF", # Perflint |
| 137 |
"PIE", # flake8-pie |
| 138 |
"PT", # flake8-pytest-style |
| 139 |
"PYI", # flake8-pyi |
| 140 |
"Q", # flake8-quotes |
| 141 |
"RUF", # Ruff-specific rules |
| 142 |
"SIM", # flake8-simplify |
| 143 |
"TC", # flake8-type-checking |
| 144 |
"UP", # pyupgrade |
| 145 |
"W", # Warning |
| 146 |
"YTT", # flake8-2020 |
| 147 |
] |
| 148 |
extend-ignore = [ |
| 149 |
"builtin-argument-shadowing", # A002 |
| 150 |
"any-type", # ANN401 (mypy's `disallow_any_explicit` is better) |
| 151 |
"module-import-not-at-top-of-file", # E402(usually OS-specific) |
| 152 |
"line-too-long", # E501 |
| 153 |
"undefined-local-with-import-star", # F403 |
| 154 |
"undefined-local-with-import-star-usage", # F405 |
| 155 |
"try-except-in-loop", # PERF203(not always possible to refactor) |
| 156 |
"pytest-raises-with-multiple-statements", # PT012 multiple statements in pytest.raises block |
| 157 |
"multiple-with-statements", # SIM117 (messes up lots of context-based stuff and looks bad) |
| 158 |
"non-empty-init-module", # RUF067 we need lots of logic in our __init__ |
| 159 |
"noqa-comments", # RUF105 replaces noqa with ruff:ignore, which is ugly and doesn't have support in black |
| 160 |
|
| 161 |
# conflicts with formatter (ruff recommends these be disabled) |
| 162 |
"missing-trailing-comma", # COM812 |
| 163 |
] |
| 164 |
|
| 165 |
[tool.ruff.lint.per-file-ignores] |
| 166 |
# Ignoring unused imports (F401) for these particular files, these are |
| 167 |
# public APIs where we are importing everything we want to export for |
| 168 |
# public use. stdlib module shadowing is A005. |
| 169 |
'src/trio/__init__.py' = ['unused-import'] |
| 170 |
'src/trio/_core/__init__.py' = ['unused-import'] |
| 171 |
'src/trio/abc.py' = ['unused-import', 'stdlib-module-shadowing'] |
| 172 |
'src/trio/lowlevel.py' = ['unused-import'] |
| 173 |
'src/trio/socket.py' = ['unused-import', 'stdlib-module-shadowing'] |
| 174 |
'src/trio/testing/__init__.py' = ['unused-import'] |
| 175 |
|
| 176 |
# Ignoring tests that are marked as async functions (RUF029) but do not |
| 177 |
# use an await in their function bodies. There are several places where |
| 178 |
# internal trio synchronous code relies on being called from an async |
| 179 |
# function, where current task is set up. |
| 180 |
# |
| 181 |
# Ignoring exact float comparison (RUF029), because we use that in |
| 182 |
# combination with autojump clocks |
| 183 |
'src/trio/_tests/*.py' = ['unused-async', 'float-equality-comparison'] |
| 184 |
'src/trio/_core/_tests/*.py' = ['unused-async', 'float-equality-comparison'] |
| 185 |
# A005 is ignoring modules that shadow stdlib modules. |
| 186 |
'src/trio/_abc.py' = ['stdlib-module-shadowing'] |
| 187 |
'src/trio/_socket.py' = ['stdlib-module-shadowing'] |
| 188 |
'src/trio/_ssl.py' = ['stdlib-module-shadowing'] |
| 189 |
|
| 190 |
[tool.ruff.lint.isort] |
| 191 |
combine-as-imports = true |
| 192 |
|
| 193 |
[tool.ruff.lint.flake8-pytest-style] |
| 194 |
fixture-parentheses = false |
| 195 |
|
| 196 |
[tool.mypy] |
| 197 |
python_version = "3.10" |
| 198 |
files = ["src/trio/", "docs/source/*.py"] |
| 199 |
|
| 200 |
# Be flexible about dependencies that don't have stubs yet (like pytest) |
| 201 |
ignore_missing_imports = true |
| 202 |
|
| 203 |
# Be strict about use of Mypy |
| 204 |
enable_error_code = ["truthy-bool", "mutable-override"] |
| 205 |
local_partial_types = true |
| 206 |
warn_unused_ignores = true |
| 207 |
warn_unused_configs = true |
| 208 |
warn_redundant_casts = true |
| 209 |
warn_return_any = true |
| 210 |
|
| 211 |
# Avoid subtle backsliding |
| 212 |
disallow_any_decorated = true |
| 213 |
disallow_any_explicit = true |
| 214 |
disallow_any_generics = true |
| 215 |
disallow_any_unimported = true |
| 216 |
disallow_incomplete_defs = true |
| 217 |
disallow_subclassing_any = true |
| 218 |
disallow_untyped_calls = true |
| 219 |
disallow_untyped_decorators = true |
| 220 |
disallow_untyped_defs = true |
| 221 |
check_untyped_defs = true |
| 222 |
|
| 223 |
[tool.pyright] |
| 224 |
pythonVersion = "3.10" |
| 225 |
reportUnnecessaryTypeIgnoreComment = true |
| 226 |
typeCheckingMode = "strict" |
| 227 |
|
| 228 |
[tool.pytest.ini_options] |
| 229 |
addopts = ["--strict-markers", "--strict-config", "-p trio._tests.pytest_plugin", "--import-mode=importlib"] |
| 230 |
faulthandler_timeout = 60 |
| 231 |
filterwarnings = [ |
| 232 |
"error", |
| 233 |
# https://gitter.im/python-trio/general?at=63bb8d0740557a3d5c688d67 |
| 234 |
'ignore:You are using cryptography on a 32-bit Python on a 64-bit Windows Operating System. Cryptography will be significantly faster if you switch to using a 64-bit Python.:UserWarning', |
| 235 |
# https://github.com/berkerpeksag/astor/issues/217 |
| 236 |
'ignore:ast.Num is deprecated:DeprecationWarning:astor', |
| 237 |
] |
| 238 |
junit_family = "xunit2" |
| 239 |
markers = ["redistributors_should_skip: tests that should be skipped by downstream redistributors"] |
| 240 |
xfail_strict = true |
| 241 |
|
| 242 |
[tool.towncrier] |
| 243 |
directory = "newsfragments" |
| 244 |
filename = "docs/source/history.rst" |
| 245 |
issue_format = "`#{issue} <https://github.com/python-trio/trio/issues/{issue}>`__" |
| 246 |
# Usage: |
| 247 |
# - PRs should drop a file like "issuenumber.feature" in newsfragments |
| 248 |
# (or "bugfix", "doc", "removal", "misc"; misc gets no text, we can |
| 249 |
# customize this) |
| 250 |
# - At release time after bumping version number, run: towncrier |
| 251 |
# (or towncrier --draft) |
| 252 |
package = "trio" |
| 253 |
package_dir = "src" |
| 254 |
underlines = ["-", "~", "^"] |
| 255 |
|
| 256 |
[[tool.towncrier.type]] |
| 257 |
directory = "headline" |
| 258 |
name = "Headline features" |
| 259 |
showcontent = true |
| 260 |
|
| 261 |
[[tool.towncrier.type]] |
| 262 |
directory = "breaking" |
| 263 |
name = "Breaking changes" |
| 264 |
showcontent = true |
| 265 |
|
| 266 |
[[tool.towncrier.type]] |
| 267 |
directory = "feature" |
| 268 |
name = "Features" |
| 269 |
showcontent = true |
| 270 |
|
| 271 |
[[tool.towncrier.type]] |
| 272 |
directory = "bugfix" |
| 273 |
name = "Bugfixes" |
| 274 |
showcontent = true |
| 275 |
|
| 276 |
[[tool.towncrier.type]] |
| 277 |
directory = "doc" |
| 278 |
name = "Improved documentation" |
| 279 |
showcontent = true |
| 280 |
|
| 281 |
[[tool.towncrier.type]] |
| 282 |
directory = "deprecated" |
| 283 |
name = "Deprecations and removals" |
| 284 |
showcontent = true |
| 285 |
|
| 286 |
[[tool.towncrier.type]] |
| 287 |
directory = "removal" |
| 288 |
name = "Removals without deprecations" |
| 289 |
showcontent = true |
| 290 |
|
| 291 |
[[tool.towncrier.type]] |
| 292 |
directory = "misc" |
| 293 |
name = "Miscellaneous internal changes" |
| 294 |
showcontent = true |
| 295 |
|
| 296 |
[tool.coverage.html] |
| 297 |
show_contexts = true |
| 298 |
skip_covered = false |
| 299 |
|
| 300 |
[tool.coverage.paths] |
| 301 |
source = ["src", "**/site-packages"] |
| 302 |
attrs-plugin = [ |
| 303 |
"tests/_trio_check_attrs_aliases.py", |
| 304 |
"_trio_check_attrs_aliases.py", |
| 305 |
] |
| 306 |
|
| 307 |
[tool.coverage.run] |
| 308 |
branch = true |
| 309 |
omit = [ |
| 310 |
# Omit the generated files in trio/_core starting with _generated_ |
| 311 |
"*/trio/_core/_generated_*", |
| 312 |
# Type tests aren't intended to be run, just passed to type checkers. |
| 313 |
"*/type_tests/*", |
| 314 |
# Script used to check type completeness that isn't run in tests |
| 315 |
"*/trio/_tests/check_type_completeness.py", |
| 316 |
# Script to generate a CFFI interface for the Windows kernel |
| 317 |
"*/trio/_tools/windows_ffi_build.py", |
| 318 |
] |
| 319 |
# The test suite spawns subprocesses to test some stuff, so make sure |
| 320 |
# this doesn't corrupt the coverage files |
| 321 |
parallel = true |
| 322 |
plugins = [] |
| 323 |
relative_files = true |
| 324 |
source = ["."] |
| 325 |
source_pkgs = ["trio", "_trio_check_attrs_aliases"] |
| 326 |
|
| 327 |
[tool.coverage.report] |
| 328 |
precision = 1 |
| 329 |
skip_covered = true |
| 330 |
skip_empty = true |
| 331 |
show_missing = true |
| 332 |
exclude_also = [ |
| 333 |
'^\s*@pytest\.mark\.xfail', |
| 334 |
"abc.abstractmethod", |
| 335 |
"if TYPE_CHECKING.*:", |
| 336 |
"if _t.TYPE_CHECKING:", |
| 337 |
"if t.TYPE_CHECKING:", |
| 338 |
"@overload", |
| 339 |
'class .*\bProtocol\b.*\):', |
| 340 |
"raise NotImplementedError", |
| 341 |
'.*if "sphinx.ext.autodoc" in sys.modules:', |
| 342 |
'TODO: test this line', |
| 343 |
'if __name__ == "__main__":', |
| 344 |
'pass', |
| 345 |
] |
| 346 |
partial_branches = [ |
| 347 |
"pragma: no branch", |
| 348 |
"if not TYPE_CHECKING:", |
| 349 |
"if not _t.TYPE_CHECKING:", |
| 350 |
"if not t.TYPE_CHECKING:", |
| 351 |
"if .* or not TYPE_CHECKING:", |
| 352 |
"if .* or not _t.TYPE_CHECKING:", |
| 353 |
"if .* or not t.TYPE_CHECKING:", |
| 354 |
'TODO: test this branch', |
| 355 |
] |