onnx
/
pyproject.toml
218 строк · 6.8 Кб
1# SPDX-License-Identifier: Apache-2.0
2
3[build-system]
4requires = ["setuptools>=64", "protobuf>=3.20.2", "cmake"]
5build-backend = "setuptools.build_meta"
6
7[project]
8name = "onnx"
9dynamic = ["version", "dependencies", "optional-dependencies"]
10description = "Open Neural Network Exchange"
11readme = "README.md"
12authors = [
13{name = "ONNX Contributors", email = "onnx-technical-discuss@lists.lfaidata.foundation"},
14]
15classifiers = [
16"Programming Language :: Python :: 3",
17]
18license = {text = "Apache License v2.0"}
19requires-python = ">=3.8"
20
21[project.urls]
22Homepage = "https://onnx.ai/"
23Repository = "https://github.com/onnx/onnx"
24
25[project.scripts]
26backend-test-tools = "onnx.backend.test.cmd_tools:main"
27check-model = "onnx.bin.checker:check_model"
28check-node = "onnx.bin.checker:check_node"
29
30[tool.setuptools.dynamic]
31dependencies = {file = "requirements.txt"}
32
33[tool.setuptools.dynamic.optional-dependencies]
34reference = {file = "requirements-reference.txt"}
35
36[tool.setuptools.packages.find]
37include = ["onnx*"]
38
39[tool.setuptools.package-data]
40onnx = [
41"**/*.c",
42"**/*.cc",
43"**/*.h",
44"**/*.proto",
45"**/*.pyi",
46"backend/test/data/**/*",
47"py.typed",
48]
49
50[tool.pytest.ini_options]
51
52addopts = "--nbval --nbval-current-env --tb=short --color=yes"
53testpaths = [
54"onnx/test",
55"onnx/examples",
56]
57
58[tool.mypy]
59follow_imports = "silent"
60strict_optional = true
61warn_return_any = true
62warn_no_return = true
63# TODO warn_unused_ignores = true
64warn_redundant_casts = true
65warn_incomplete_stub = true
66# TODO disallow_untyped_calls = true
67check_untyped_defs = true
68# Allow bare generics like np.ndarray
69disallow_any_generics = false
70no_implicit_optional = true
71# TODO disallow_incomplete_defs = true
72# TODO disallow_subclassing_any = true
73warn_unused_configs = true
74show_error_codes = true
75show_column_numbers = true
76ignore_missing_imports = true
77# NOTE: Do not grow the exclude list. Edit .lintrunner.toml instead
78exclude = [
79'^third_party',
80]
81
82# NOTE: Avoid adding overrides unless for exceptional cases. Prefer inline ignores.
83# If you must ignore error for the whole file, consider adapting the example
84# `# mypy: disable-error-code="misc,arg-type,type-arg"`
85# and put this comment on the top of the file.
86[[tool.mypy.overrides]]
87module = [
88'onnx.onnx_data_pb',
89'onnx.onnx_data_pb2',
90'onnx.onnx_pb',
91'onnx.onnx_pb2',
92'onnx.onnx_ml_pb2',
93'onnx.onnx_operators_pb',
94'onnx.onnx_operators_ml_pb2',
95]
96ignore_errors = true
97
98[tool.black]
99# NOTE: Do not create an exclude list. Edit .lintrunner.toml instead
100target-version = ["py38", "py39", "py310", "py311"]
101
102[tool.isort]
103# NOTE: Do not create an exclude list. Edit .lintrunner.toml instead
104profile = "black"
105
106[tool.pylint.message_control]
107# This list is for vscode. Add new disables in pyproject_pylint.toml for lintrunner and CI.
108# Exclude patterns should be modified in .lintrunner.toml
109disable = [
110"format",
111"import-error",
112"line-too-long",
113"no-name-in-module",
114"use-dict-literal", # Dict literals are sometimes preferable when creating kwargs
115"useless-return",
116]
117
118[tool.ruff]
119# NOTE: Do not create an exclude list. Edit .lintrunner.toml instead
120target-version = "py38"
121unsafe-fixes = true
122lint.select = [
123"A", # flake8-builtins
124"ARG", # flake8-unused-arguments
125"B", # flake8-bugbear
126"BLE", # flake8-blind-except
127"C4", # flake8-comprehensions
128"D", # pydocstyle
129"E", # pycodestyle
130"F", # Pyflakes
131"FA", # flake8-future-annotations
132"G", # flake8-logging-format
133"I002", # isort: required imports
134"ISC", # flake8-implicit-str-concat
135"LOG", # flake8-logging
136"N", # pep8-naming
137"NPY", # modern numpy
138"PERF", # Perflint
139"PIE", # flake8-pie
140"PL", # pylint
141"PYI", # flake8-pyi
142"RUF", # Ruff-specific rules
143"SIM", # flake8-simplify
144"SLOT", # flake8-slot
145"T10", # flake8-debugger
146"TID", # Disallow relative imports
147"TRY", # flake8-try-except-raise
148"UP", # pyupgrade
149"W", # pycodestyle
150"YTT", # flake8-2020
151]
152# NOTE: Refrain from growing the ignore list unless for exceptional cases.
153# Always include a comment to explain why.
154lint.ignore = [
155"D1", # D1 is for missing docstrings, which is not yet enforced.
156"D205", # D205 Too strict. "1 blank line required between summary line and description"
157"D400",
158"D415",
159"E501", # Line length controlled by black
160"N803", # Argument casing
161"N806", # Relax: Variable name in function should be lowercase
162"N999", # Module names
163"NPY002", # np.random.Generator may not be preferred in all cases
164"PLR0912", # Too many branches
165"PLR0913", # Too many arguments to function call
166"PLR0915", # Too many statements
167"PYI011", # Allow protobuf enums as defaults to function arguments
168"PYI021", # Allow docstrings in pyi files
169"PYI041", # int | float is sometimes more clear than float
170"RUF015", # next(iter(...)) sometimes obscures the intent when we access the 0th element of a shape
171"SIM102", # We don't perfer always combining if branches
172"SIM108", # We don't always encourage ternary operators
173"SIM114", # Don't always combine if branches for debugability
174"SIM116", # Don't use dict lookup to replace if-else
175"TRY003", # Messages can be constructed in the exception
176]
177lint.ignore-init-module-imports = false
178lint.unfixable = [
179"SIM112", # Envvars should not be modified
180]
181
182[tool.ruff.lint.flake8-builtins]
183builtins-ignorelist = ["id", "input"]
184
185[tool.ruff.lint.flake8-tidy-imports]
186# Disallow all relative imports.
187ban-relative-imports = "all"
188
189[tool.ruff.lint.pydocstyle]
190convention = "google"
191
192[tool.ruff.lint.isort]
193required-imports = ["from __future__ import annotations"]
194
195[tool.ruff.lint.per-file-ignores]
196"**/*.pyi" = ["I002"] # from __future__ import annotations` has no effect in stub files
197# NOTE: Refrain from growing the ignore list unless for exceptional cases.
198# Prefer inline ignores with `noqa: xxx`.
199# Eventually this list should become empty.
200"**/*_test*" = ["N802"] # Function casing
201"onnx/backend/test/**" = ["PLR2004"] # Magic numbers allowed in tests
202"onnx/backend/test/case/**" = ["N802"] # Function casing
203"onnx/reference/ops/**" = [
204"N801", # Class casing
205"PLR2004", # Magic numbers
206]
207"onnx/reference/ops/_op_list.py" = ["F401"]
208"onnx/__init__.py" = ["F401"]
209"onnx/reference/__init__.py" = ["F401"]
210"onnx/reference/ops/__init__.py" = ["F401"]
211"onnx/reference/ops/aionnxml/_op_list.py" = ["F401"]
212"onnx/reference/ops/aionnxml/__init__.py" = ["F401"]
213"onnx/reference/ops/aionnx_preview_training/__init__.py" = ["F401"]
214"onnx/reference/ops/aionnx_preview_training/_op_list.py" = ["F401"]
215"onnx/reference/ops/experimental/__init__.py" = ["F401"]
216"onnx/test/reference_evaluator_test.py"= ["C408"] # dict(...) -> { ... }
217"onnx/test/**" = ["PLR2004"] # Magic numbers allowed in tests
218"onnx/onnx_cpp2py_export/defs.pyi" = ["N802"]
219