-
Notifications
You must be signed in to change notification settings - Fork 7
/
pyproject.toml
287 lines (264 loc) · 7.65 KB
/
pyproject.toml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
# Package ######################################################################
[build-system]
requires = ["setuptools", "cmake >= 3.18", "pybind11 >= 2.12"]
build-backend = "setuptools.build_meta"
[project]
name = "optree"
description = "Optimized PyTree Utilities."
readme = "README.md"
requires-python = ">= 3.7"
authors = [
{ name = "OpTree Contributors" },
{ name = "Xuehai Pan", email = "[email protected]" },
{ name = "Jie Ren", email = "[email protected]" },
]
license = { text = "Apache License, Version 2.0" }
keywords = [
"PyTree",
"Tree Manipulation",
"Tree Traversal",
"Functional Programming",
]
classifiers = [
"Development Status :: 4 - Beta",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: C++",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux",
"Operating System :: MacOS",
"Intended Audience :: Developers",
"Intended Audience :: Education",
"Intended Audience :: Science/Research",
"Topic :: Utilities",
]
dependencies = ["typing-extensions >= 4.5.0"]
dynamic = ["version"]
[project.urls]
Homepage = "https://github.com/metaopt/optree"
Repository = "https://github.com/metaopt/optree"
Documentation = "https://optree.readthedocs.io"
"Bug Report" = "https://github.com/metaopt/optree/issues"
[project.optional-dependencies]
jax = ["jax"]
numpy = ["numpy"]
torch = ["torch"]
lint = [
"isort",
"black",
"pylint[spelling]",
"mypy",
"flake8",
"flake8-bugbear",
"flake8-comprehensions",
"flake8-docstrings",
"flake8-pyi",
"flake8-simplify",
"ruff",
"doc8",
"pydocstyle",
"pyenchant",
"xdoctest",
"cpplint",
"pre-commit",
]
test = ["pytest", "pytest-cov", "pytest-xdist"]
docs = [
"sphinx",
"sphinx-autoapi",
"sphinx-autobuild",
"sphinx-copybutton",
"sphinx-rtd-theme",
"sphinxcontrib-bibtex",
"sphinx-autodoc-typehints",
"docutils",
"jax[cpu]",
"numpy",
"torch",
]
benchmark = [
"jax[cpu] >= 0.4.6, < 0.5.0a0",
"torch >= 2.0, < 2.4.0a0",
"torchvision",
"dm-tree >= 0.1, < 0.2.0a0",
"pandas",
"tabulate",
"termcolor",
]
[tool.setuptools]
include-package-data = true
[tool.setuptools.packages.find]
include = ["optree", "optree.*"]
[tool.setuptools.package-data]
optree = ['*.so', '*.pyd']
# Wheel builder ################################################################
# Reference: https://cibuildwheel.readthedocs.io
[tool.cibuildwheel]
archs = ["native"]
free-threaded-support = true
skip = "*musllinux*"
build-frontend = "build"
test-extras = ["test"]
test-command = '''make -C "{project}" test PYTHON=python PYTESTOPTS="--quiet --exitfirst --no-showlocals"'''
# Linter tools #################################################################
[tool.black]
line-length = 100
skip-string-normalization = true
target-version = ["py37"]
[tool.isort]
atomic = true
profile = "black"
src_paths = ["optree", "tests"]
extra_standard_library = ["typing_extensions"]
indent = 4
line_length = 100
lines_after_imports = 2
multi_line_output = 3
[tool.mypy]
python_version = "3.8"
exclude = ["^setup\\.py$", "^tests/.*\\.py$"]
pretty = true
show_column_numbers = true
show_error_codes = true
show_error_context = true
show_traceback = true
allow_redefinition = true
check_untyped_defs = true
disallow_incomplete_defs = true
disallow_untyped_defs = true
ignore_missing_imports = true
no_implicit_optional = true
strict_equality = true
strict_optional = true
warn_no_return = true
warn_redundant_casts = true
warn_unreachable = true
warn_unused_configs = true
warn_unused_ignores = true
no_site_packages = true
[tool.pylint]
main.py-version = "3.7"
main.extension-pkg-allow-list = ["optree._C"]
main.ignore-paths = ["^_C/$", "^tests/$"]
basic.good-names = []
design.max-args = 7
format.max-line-length = 120
"messages control".disable = ["duplicate-code"]
"messages control".enable = ["c-extension-no-member"]
spelling.spelling-dict = "en_US"
spelling.spelling-private-dict-file = "docs/source/spelling_wordlist.txt"
typecheck.generated-members = ["numpy.*", "torch.*"]
[tool.pydocstyle]
convention = "google"
[tool.doc8]
max-line-length = 500
[tool.codespell]
ignore-words = "docs/source/spelling_wordlist.txt"
[tool.ruff]
target-version = "py37"
line-length = 100
output-format = "full"
src = ["optree", "tests"]
[tool.ruff.lint]
select = [
"E", "W", # pycodestyle
"F", # pyflakes
"C90", # mccabe
"N", # pep8-naming
"UP", # pyupgrade
"ANN", # flake8-annotations
"S", # flake8-bandit
"BLE", # flake8-blind-except
"B", # flake8-bugbear
"COM", # flake8-commas
"C4", # flake8-comprehensions
"EXE", # flake8-executable
"FA", # flake8-future-annotations
"LOG", # flake8-logging
"ISC", # flake8-implicit-str-concat
"INP", # flake8-no-pep420
"PIE", # flake8-pie
"PYI", # flake8-pyi
"Q", # flake8-quotes
"RSE", # flake8-raise
"RET", # flake8-return
"SIM", # flake8-simplify
"TID", # flake8-tidy-imports
"TCH", # flake8-type-checking
"PERF", # perflint
"FURB", # refurb
"TRY", # tryceratops
"RUF", # ruff
]
ignore = [
# E501: line too long
# W505: doc line too long
# too long docstring due to long example blocks
"E501",
"W505",
# ANN101: missing type annotation for `self` in method
# ANN102: missing type annotation for `cls` in classmethod
"ANN101",
"ANN102",
# ANN401: dynamically typed expressions (typing.Any) are disallowed
"ANN401",
# N999: invalid module name
# optree._C is not snake_cased
"N999",
# S101: use of `assert` detected
# internal use and may never raise at runtime
"S101",
# TRY003: avoid specifying long messages outside the exception class
# long messages are necessary for clarity
"TRY003",
]
typing-modules = ["optree.typing"]
[tool.ruff.lint.per-file-ignores]
"__init__.py" = [
"F401", # unused-import
]
"optree/typing.py" = [
"E402", # module-import-not-at-top-of-file
"F722", # forward-annotation-syntax-error
"F811", # redefined-while-unused
]
"setup.py" = [
"ANN", # flake8-annotations
]
"tests/**/*.py" = [
"ANN", # flake8-annotations
"S", # flake8-bandit
"BLE", # flake8-blind-except
"SIM", # flake8-simplify
"INP001", # flake8-no-pep420
"E402", # module-import-not-at-top-of-file
]
"docs/source/conf.py" = [
"ANN", # flake8-annotations
"INP001", # flake8-no-pep420
]
[tool.ruff.lint.flake8-annotations]
allow-star-arg-any = true
[tool.ruff.lint.flake8-quotes]
docstring-quotes = "double"
multiline-quotes = "double"
inline-quotes = "single"
[tool.ruff.lint.flake8-tidy-imports]
ban-relative-imports = "all"
[tool.pytest.ini_options]
verbosity_assertions = 3
filterwarnings = [
"error",
"always",
"ignore:The class `optree.Partial` is deprecated and will be removed in a future version. Please use `optree.functools.partial` instead.:FutureWarning",
"ignore:The key path API is deprecated and will be removed in a future version. Please use the accessor API instead.:FutureWarning",
]