From 321ec76535707508195299d6bc87d0622fea6e7b Mon Sep 17 00:00:00 2001 From: Shyue Ping Ong Date: Fri, 28 Jun 2024 10:17:49 -0700 Subject: [PATCH] Add ruff rules for notebook. --- pyproject.toml | 142 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 142 insertions(+) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..59c4b16 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,142 @@ +[tool.versioningit.vcs] +method = "git" +default-tag = "0.0.1" + +[tool.cibuildwheel.linux] +archs = ["auto64"] +skip = ["*musllinux*"] +before-all = "ln -s /usr/lib64/libgfortran.so.5 /usr/lib64/libgfortran.so.3" + +[tool.cibuildwheel.macos] +repair-wheel-command = "delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel} --ignore-missing-dependencies" + +[tool.ruff] +target-version = "py39" +line-length = 120 +extend-include = ["*.ipynb"] + +[tool.ruff.lint] +select = ["ALL"] +ignore = [ + # Rule families + "ANN", # flake8-annotations (not ready, require types for ALL args) + "ARG", # Check for unused function arguments + "BLE", # General catch of Exception + "C90", # Check for functions with a high McCabe complexity + "COM", # flake8-commas (conflict with line wrapper) + "CPY", # Missing copyright notice at top of file (need preview mode) + "EM", # Format nice error messages + "ERA", # Check for commented-out code + "FIX", # Check for FIXME, TODO and other developer notes + "FURB", # refurb (need preview mode, too many preview errors) + "G", # validate logging format strings + "INP", # Ban PEP-420 implicit namespace packages + "N", # pep8-naming (many var/arg names are intended) + "NPY", # NumPy-specific rules (TODO: enable this) + "PTH", # Prefer pathlib over os.path + "S", # flake8-bandit (TODO: enable this) + "SLF", # Access "private" class members + "T20", # Check for print/pprint + "TD", # TODO tags related + + # Single rules + "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 + "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 + "DTZ003", # TODO: fix this (issue #3791) + "FBT001", # Boolean-typed positional argument in function definition + "FBT002", # Boolean default positional argument in function + "PD901", # pandas-df-variable-name + "PERF203", # try-except-in-loop + "PERF401", # manual-list-comprehension + "PLR0911", # too many return statements + "PLR0912", # too many branches + "PLR0913", # too many arguments + "PLR0915", # too many statements + "PLR2004", # magic values in comparison + "PLW2901", # Outer for loop variable overwritten by inner assignment target + "PT013", # pytest-incorrect-pytest-import + "SIM105", # Use contextlib.suppress() instead of try-except-pass + "TRY003", # Avoid specifying long messages outside the exception class + "TRY300", # Checks for return statements in try blocks + "TRY301", # Checks for raise statements within try blocks +] +pydocstyle.convention = "google" +isort.required-imports = ["from __future__ import annotations"] +isort.split-on-trailing-comma = false + +[tool.ruff.format] +docstring-code-format = true + +[tool.ruff.lint.per-file-ignores] +"__init__.py" = ["F401"] +"tests/**" = ["ANN201", "D", "PLR0124"] +"src/pymatgen/analysis/*" = ["D"] +"src/pymatgen/io/*" = ["D"] +"dev_scripts/*" = ["D"] + +[tool.pytest.ini_options] +addopts = "--durations=30 --quiet -r xXs --color=yes -p no:warnings --import-mode=importlib" + +[tool.coverage.run] +parallel = true +omit = [ + "pymatgen/cli/feff_plot_cross_section.py", + "pymatgen/cli/feff_plot_dos.py", + "pymatgen/cli/pmg_config.py", + "pymatgen/cli/pmg_plot.py", + "pymatgen/cli/pmg_potcar.py", + "pymatgen/cli/pmg_query.py", + "pymatgen/dao.py", +] + +[tool.coverage.report] +exclude_also = [ + "@deprecated", + "@np.deprecate", + "def __repr__", + "except ImportError:", + "if 0:", + "if TYPE_CHECKING:", + "if __name__ == .__main__.:", + "if self.debug:", + "if settings.DEBUG", + "if typing.TYPE_CHECKING:", + "pragma: no cover", + "raise AssertionError", + "raise NotImplementedError", + "show_plot", +] + +[tool.mypy] +ignore_missing_imports = true +namespace_packages = true +explicit_package_bases = true +no_implicit_optional = false +disable_error_code = "annotation-unchecked" + +[[tool.mypy.overrides]] +module = ["requests.*", "tabulate.*"] +ignore_missing_imports = true + +[tool.codespell] +ignore-words-list = """ +titel,alls,ans,nd,mater,nwo,te,hart,ontop,ist,ot,fo,nax,coo, +coul,ser,leary,thre,fase,rute,reson,titels,ges,scalr,strat, +struc,hda,nin,ons,pres,kno,loos,lamda,lew,atomate,nempty +""" +skip = "pymatgen/analysis/aflow_prototypes.json" +check-filenames = true + +[tool.pyright] +typeCheckingMode = "off" +reportPossiblyUnboundVariable = true +reportUnboundVariable = true +reportMissingImports = false +reportMissingModuleSource = false +reportInvalidTypeForm = false +exclude = ["**/tests"]