mirror of
https://github.com/huggingface/peft.git
synced 2025-10-20 15:33:48 +08:00
Subjectively, there have been more issues recently with contributor PRs being rejected by ruff. This could possibly be caused by them using a different ruff version (presumably: more recent). This PR upgrades ruff to the latest version to hopefully reduce these issues. The only change needed to make this ruff version pass was to disable UP045. This rule requires changing code like: x: Optional[int] into x: int | None in 220 places. Personally, I don't think it's crucial. Moreover, ruff won't fix this automically, except with --unsafe-fixes (note that Python 3.9 needs a __future__ import for this, so that could be the reason). My preference is thus just to disable the rule, but LMK if you disagree.
52 lines
1.2 KiB
TOML
52 lines
1.2 KiB
TOML
[tool.black]
|
||
# Only used by `hf-doc-builder´.
|
||
line-length = 119
|
||
target-version = ['py38']
|
||
|
||
[tool.ruff]
|
||
target-version = "py39"
|
||
line-length = 119
|
||
extend-exclude = ["*.ipynb"]
|
||
|
||
[tool.ruff.lint]
|
||
preview = true
|
||
explicit-preview-rules = true
|
||
extend-select = [
|
||
"C", # Complexity
|
||
"E", # PEP8 errors
|
||
"F", # PEP8 formatting
|
||
"I", # Import sorting
|
||
"UP", # Pyupgrade upgrades
|
||
"W", # PEP8 warnings
|
||
"PT009", # Pytest assertions
|
||
"RUF022", # Sorting of __all__
|
||
]
|
||
ignore = [
|
||
"C901", # Function too complex
|
||
"E501", # Line length (handled by ruff-format)
|
||
"F841", # unused variable
|
||
"UP007", # X | Y style Unions
|
||
"C420", # dict.fromkeys
|
||
"UP045", # don't force replacing Optional[X] with X | None
|
||
]
|
||
|
||
[tool.ruff.lint.isort]
|
||
lines-after-imports = 2
|
||
known-first-party = ["peft"]
|
||
|
||
[tool.pytest]
|
||
doctest_optionflags = [
|
||
"NORMALIZE_WHITESPACE",
|
||
"ELLIPSIS",
|
||
"NUMBER",
|
||
]
|
||
|
||
[tool.pytest.ini_options]
|
||
addopts = "--cov=src/peft --cov-report=term-missing --durations=10"
|
||
markers = [
|
||
"single_gpu_tests: tests that run on a single GPU",
|
||
"multi_gpu_tests: tests that run on multiple GPUs",
|
||
"regression: whether to run regression suite test",
|
||
"bitsandbytes: select bitsandbytes integration tests"
|
||
]
|