mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-17 21:10:43 +00:00
Use ruff as the code formatter in place of black and isort since it is much faster, and as projects like PyTorch and ONNX have adopted ruff format as well. This PR include only auto-fixed changes in formatting.
71 lines
2.8 KiB
TOML
71 lines
2.8 KiB
TOML
[tool.pydocstyle]
|
|
convention = "google"
|
|
|
|
[tool.pyright]
|
|
exclude = ["onnxruntime/core/flatbuffers/*"]
|
|
reportMissingImports = false
|
|
|
|
[tool.ruff]
|
|
# NOTE: Do not create an exclude list. Edit .lintrunner.toml instead
|
|
target-version = "py38"
|
|
line-length = 120
|
|
|
|
[tool.ruff.lint]
|
|
select = [
|
|
"B", # flake8-bugbear
|
|
"E", # pycodestyle
|
|
"F", # Pyflakes
|
|
"FURB", # refurb
|
|
"G", # flake8-logging-format
|
|
"I", # isort
|
|
"ISC", # flake8-implicit-str-concat
|
|
"N", # pep8-naming
|
|
"NPY", # numpy
|
|
"PERF", # Perflint
|
|
"PIE", # flake8-pie
|
|
"PLC", # pylint conventions
|
|
"PLE", # pylint errors
|
|
"PLW", # pylint warnings
|
|
"PYI", # flake8-pyi
|
|
"RUF", # Ruff-specific rules
|
|
"SIM", # flake8-simplify
|
|
"SLOT", # flake8-slots
|
|
"T10", # flake8-debugger
|
|
"UP", # pyupgrade
|
|
"W", # pycodestyle
|
|
"YTT", # flake8-2020
|
|
]
|
|
# NOTE: Refrain from growing the ignore list unless for exceptional cases.
|
|
# Always include a comment to explain why.
|
|
ignore = [
|
|
"B028", # FIXME: Add stacklevel to warnings
|
|
"E501", # Line length controlled by black
|
|
"G004", # FIXME: Enable when the rule can be autofixed
|
|
"N803", # Argument casing
|
|
"N812", # Allow import torch.nn.functional as F
|
|
"N813", # Allow importing camelcase names in lowercase
|
|
"N999", # Module names
|
|
"NPY002", # np.random.Generator may not always fit our use cases
|
|
"PERF203", # "try-except-in-loop" only affects Python <3.11, and the improvement is minor; can have false positives
|
|
"PERF401", # List comprehensions are not always readable
|
|
"PYI041", # May create confusion
|
|
"PYI024", # May create confusion
|
|
"SIM102", # We don't perfer always combining if branches
|
|
"SIM103", # Do not collapse if-else
|
|
"SIM108", # We don't encourage ternary operators
|
|
"SIM114", # Don't combine if branches for debugability
|
|
"SIM116", # Don't use dict lookup to replace if-else
|
|
]
|
|
ignore-init-module-imports = true
|
|
|
|
[tool.ruff.lint.per-file-ignores]
|
|
# NOTE: Refrain from growing the ignore list unless for exceptional cases.
|
|
# Prefer inline ignores with `noqa: xxx`.
|
|
# Eventually this list should become empty.
|
|
"orttraining/orttraining/test/**" = ["N802"] # Function casing
|
|
"tools/nuget/generate_nuspec_for_native_nuget.py" = ["ISC003"] # Too many errors to fix
|
|
"onnxruntime/contrib_ops/cuda/sparse/sparse_attention_v1/sparse_attention_triton.py" = ["N806"] # use of Q, K and V in triton script
|
|
"onnxruntime/contrib_ops/cuda/sparse/sparse_attention_v2/sparse_attention_v2_triton.py" = ["N806"] # use of Q, K and V in triton script
|
|
"onnxruntime/test/python/quantization/test_op_gemm.py" = ["N806"] # use of A for a matrix
|
|
"onnxruntime/test/python/quantization/op_test_utils.py" = ["N806", "PERF203", "RUF012"] # use of A for a matrix
|
|
"orttraining/orttraining/python/training/ort_triton/kernel/_flash_attn.py" = ["N806", "PLW2901", "ISC001", "E731"] # Long triton code from other repo.
|