From 4f2af1822b3fa0bf0f196eb37992b530a3c99747 Mon Sep 17 00:00:00 2001 From: Tingzheng Hou Date: Sun, 4 Feb 2024 10:58:30 +0800 Subject: [PATCH] Initial update pyproject.toml to ruff --- pyproject.toml | 87 +++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 68 insertions(+), 19 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 2ce1ae82..e1480f13 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,24 +5,73 @@ requires = [ ] build-backend = "setuptools.build_meta" -[tool.black] +[tool.ruff] +target-version = "py39" line-length = 120 -target-version = ['py310'] -include = '\.pyi?$' -exclude = ''' +lint.select = [ + "B", # flake8-bugbear + "C4", # flake8-comprehensions + "D", # pydocstyle + "E", # pycodestyle error + "EXE", # flake8-executable + "F", # pyflakes + "FA", # flake8-future-annotations + "FBT003", # boolean-positional-value-in-call + "FLY", # flynt + "I", # isort + "ICN", # flake8-import-conventions + "ISC", # flake8-implicit-str-concat + "PD", # pandas-vet + "PERF", # perflint + "PIE", # flake8-pie + "PL", # pylint + "PT", # flake8-pytest-style + "PYI", # flakes8-pyi + "Q", # flake8-quotes + "RET", # flake8-return + "RSE", # flake8-raise + "RUF", # Ruff-specific rules + "SIM", # flake8-simplify + "SLOT", # flake8-slots + "TCH", # flake8-type-checking + "TID", # tidy imports + "TID", # flake8-tidy-imports + "UP", # pyupgrade + "W", # pycodestyle warning + "YTT", # flake8-2020 +] +lint.ignore = [ + "B023", # Function definition does not bind loop variable + "B028", # No explicit stacklevel keyword argument found + "B904", # Within an except clause, raise exceptions with ... + "C408", # unnecessary-collection-call + "COM812", # missing trailing comma + "D105", # Missing docstring in magic method + "D205", # 1 blank line required between summary line and description + "D212", # Multi-line docstring summary should start at the first line + "NPY002", # replace legacy numpy.random with numpy.random.Generator + "PD901", # pandas-df-variable-name + "PERF203", # try-except-in-loop + "PERF401", # manual-list-comprehension (TODO fix these or wait for autofix) + "PLC1901", # can be simplified to ... as empty is falsey + "PLR", # pylint refactor + "PLW1514", # open() without explicit encoding argument + "PLW2901", # Outer for loop variable overwritten by inner assignment target + "PT013", # pytest-incorrect-pytest-import + "PTH", # prefer pathlib to os.path + "PYI024", # collections-named-tuple (TODO should maybe fix these) + "RUF012", # Disable checks for mutable class args. This is a non-problem. + "SIM105", # Use contextlib.suppress(OSError) instead of try-except-pass +] +lint.pydocstyle.convention = "google" +lint.isort.required-imports = ["from __future__ import annotations"] +lint.isort.split-on-trailing-comma = false -( - /( - \.eggs # exclude a few common directories in the - | \.git # root of the project - | \.hg - | \.mypy_cache - | \.tox - | \.venv - | _build - | buck-out - | build - | dist - )/ -) -''' \ No newline at end of file +[tool.ruff.lint.per-file-ignores] +"__init__.py" = ["F401"] +"tests/**" = ["ANN201", "D", "S101"] +"tasks.py" = ["D"] +"pymatgen/analysis/*" = ["D"] +"pymatgen/vis/*" = ["D"] +"pymatgen/io/*" = ["D"] +"dev_scripts/*" = ["D"]