-
Notifications
You must be signed in to change notification settings - Fork 56
/
pyproject.toml
224 lines (203 loc) · 6.89 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
[build-system]
requires = ["setuptools>=61.0.0"]
build-backend = "setuptools.build_meta"
[project]
name = "onnxscript"
dynamic = ["version", "urls"]
description = "Naturally author ONNX functions and models using a subset of Python"
authors = [{ name = "Microsoft Corporation", email = "[email protected]" }]
readme = "README.md"
requires-python = ">=3.8"
license = { file = "LICENSE" }
classifiers = [
"Development Status :: 4 - Beta",
"Environment :: Console",
"Intended Audience :: Developers",
"Operating System :: POSIX",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
"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",
"License :: OSI Approved :: MIT License",
]
dependencies = ["numpy", "onnx>=1.16", "typing_extensions", "ml_dtypes", "packaging"]
[tool.setuptools.packages.find]
include = ["onnxscript*"]
[tool.setuptools.package-data]
onnxscript = ["py.typed"]
onnx = ["py.typed"]
[tool.pytest.ini_options]
filterwarnings = ["ignore::UserWarning", "ignore::DeprecationWarning"]
addopts = "-rsfEX --tb=short --color=yes"
[tool.mypy]
# TODO disallow_incomplete_defs = true
check_untyped_defs = true
disable_error_code = 'override,import-untyped'
disallow_any_generics = false
disallow_untyped_decorators = true
show_column_numbers = true
strict_optional = true
warn_incomplete_stub = true
warn_no_return = true
warn_redundant_casts = true
warn_unused_configs = true
warn_unused_ignores = false
[[tool.mypy.overrides]]
module = [
"onnx.*",
"onnxruntime.*",
"parameterized.*",
"torchgen.*",
]
ignore_missing_imports = true
[[tool.mypy.overrides]]
module = "tools.*"
disallow_untyped_defs = true
# Ignore errors in test
[[tool.mypy.overrides]]
module = [
"setup",
"tests.models.*",
"tests.onnx_backend_test_code.*",
]
ignore_errors = true
# FIXME(#1378): Remove this overrides section
[[tool.mypy.overrides]]
module = [
"onnxrewriter.rewriter.generic_pattern_test.*",
]
check_untyped_defs = false
disable_error_code = 'override,import-untyped,no-untyped-def,assignment'
disallow_incomplete_defs = true
disallow_untyped_defs = true
disallow_untyped_decorators = true
show_column_numbers = true
strict_optional = true
warn_incomplete_stub = true
warn_no_return = true
warn_unused_configs = true
warn_unused_ignores = false
# FIXME(#1378): Remove this overrides section
[[tool.mypy.overrides]]
module = [
"onnxrewriter.rewriter.generic_pattern.*",
]
check_untyped_defs = false
disable_error_code = 'override,import-untyped,no-untyped-def,assignment,union-attr,func-returns-value,annotation-unchecked,arg-type,index,name-defined,attr-defined'
disallow_incomplete_defs = true
disallow_untyped_defs = true
disallow_untyped_decorators = true
show_column_numbers = true
strict_optional = true
warn_incomplete_stub = true
warn_no_return = true
warn_unused_configs = true
warn_unused_ignores = false
[tool.black]
target-version = ["py39", "py310", "py311"]
# Black's extend-exclude needs to be a regex string
extend-exclude = "/tests/models|/tests/onnx_backend_test_code"
line-length = 95
[tool.isort]
profile = "black"
extend_skip_glob = [
"tests/onnx_backend_test_code/*.py",
]
[tool.pylint.messages_control]
# NOTE: This list is for vscode. Add new disables in pyproject_pylint.toml for lintrunner
# Exclude patterns should be modified in .lintrunner.toml
disable = [
"consider-using-from-import",
"format",
"import-error",
"invalid-name", # TODO: Add naming guidance and enable this check.
"line-too-long",
"no-name-in-module",
"unnecessary-ellipsis",
"use-dict-literal", # Sometime it is preferable when we construct kwargs
]
[tool.pydocstyle]
convention = "google"
[tool.ruff]
line-length = 95
target-version = "py38"
[tool.ruff.lint]
select = [
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"D", # pydocstyle
"E", # pycodestyle
"F", # Pyflakes
"G", # flake8-logging-format
"I", # isort
"ISC", # flake8-implicit-str-concat
"LOG", # flake8-logging
"N", # pep8-naming
"NPY", # modern numpy
"PERF", # Perflint
"PIE", # flake8-pie
"PYI", # flake8-pyi
"RUF", # Ruff-specific rules
"SIM", # flake8-simplify
"SLOT", # flake8-slot
"T10", # flake8-debugger
"TID", # Disallow relative imports
"TRY", # flake8-try-except-raise
"UP", # pyupgrade
"W", # pycodestyle
"YTT", # flake8-2020
]
# Select preview rules
preview = true
extend-select = [
"CPY001", # Copyright header
]
ignore = [
"B9", # Opinionated bugbear rules
"C408", # Sometimes it is preferable when we construct kwargs
"D1", # D1 is for missing docstrings, which is not yet enforced.
"D202", # D202 Too strict. "No blank lines allowed after function docstring"
"D205", # D205 Too strict. "1 blank line required between summary line and description"
"D212",
"D400",
"D401", # First line of docstring should be in imperative mood
"D415", # D415 Not yet enforced. "First line should end with a period, question mark, or exclamation point"
"E1", "E2", "E3", # Pycodestyle formatting rules that conflicts with the formatter
"E501", # Line length. Not enforced because black will handle formatting
"SIM103", # "Return the condition directly" obscures logic sometimes
"N802", # Nxx: ONNX Script function sometimes use upper case for names.
"N803",
"N806",
"N999", # Invalid module name
"NPY002", # We may not always need a generator
"PERF203", # try-except in loops sometimes necessary
"PERF401", # List comprehension is not always readable
"PYI041", # int | float is more clear
"RUF022", # We don't need to sort __all__ for elements to be grouped
"RUF031", # Parentheses for tuple in subscripts is more readable
"SIM102", # Collapible if statements are not always more readable
"SIM108", # We don't always encourage ternary operators
"SIM114", # Don't always combine if branches for debugability
"SIM116", # Don't use dict lookup to replace if-else
"TRY003", # Messages can be constructed in the exception
"UP006", # keep-runtime-typing
"UP007", # keep-runtime-typing
]
ignore-init-module-imports = true
[tool.ruff.lint.flake8-tidy-imports.banned-api]
"pathlib".msg = "Using pathlib can impact performance. Use os.path instead"
[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["TID252"] # Allow relative imports in init files
"setup.py" = ["TID251"] # pathlib is allowed in supporting code
"**/{examples,tests,docs,tools,utils,opgen,_framework_apis}/*" = ["TID251"] # pathlib is allowed in supporting code
"**/*_test.py" = ["TID251"] # pathlib is allowed in tests
[tool.ruff.lint.flake8-tidy-imports]
# Disallow all relative imports.
ban-relative-imports = "all"
[tool.ruff.lint.pydocstyle]
convention = "google"
[tool.ruff.lint.flake8-copyright]
notice-rgx = "(?i)Copyright \\(c\\) Microsoft Corporation"