Skip to content

Commit

Permalink
unignore ruff FBT001 FBT002 and fix existing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
janosh committed Jun 9, 2024
1 parent 1342d9e commit cae9d94
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 14 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ci:

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.4
rev: v0.4.8
hooks:
- id: ruff
args: [--fix]
Expand All @@ -26,7 +26,7 @@ repos:
- id: mypy

- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
rev: v2.3.0
hooks:
- id: codespell
stages: [commit, commit-msg]
Expand All @@ -48,6 +48,6 @@ repos:
args: [--drop-empty-cells, --keep-output]

- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.362
rev: v1.1.366
hooks:
- id: pyright
1 change: 1 addition & 0 deletions matcalc/elasticity.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class ElasticityCalc(PropCalc):
def __init__(
self,
calculator: Calculator,
*,
norm_strains: Sequence[float] | float = (-0.01, -0.005, 0.005, 0.01),
shear_strains: Sequence[float] | float = (-0.06, -0.03, 0.03, 0.06),
fmax: float = 0.1,
Expand Down
1 change: 1 addition & 0 deletions matcalc/eos.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class EOSCalc(PropCalc):
def __init__(
self,
calculator: Calculator,
*,
optimizer: Optimizer | str = "FIRE",
max_steps: int = 500,
max_abs_strain: float = 0.1,
Expand Down
2 changes: 2 additions & 0 deletions matcalc/neb.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class NEBCalc(PropCalc):
def __init__(
self,
images: list[Structure],
*,
calculator: str | Calculator = "M3GNet-MP-2021.2.8-DIRECT-PES",
optimizer: str | Optimizer = "BFGS",
traj_folder: str | None = None,
Expand Down Expand Up @@ -63,6 +64,7 @@ def from_end_images(
start_struct: Structure,
end_struct: Structure,
calculator: str | Calculator = "M3GNet-MP-2021.2.8-DIRECT-PES",
*,
n_images: int = 7,
interpolate_lattices: bool = False,
autosort_tol: float = 0.5,
Expand Down
3 changes: 2 additions & 1 deletion matcalc/phonon.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ class PhononCalc(PropCalc):
write_phonon: bool | str | Path = True

def __post_init__(self) -> None:
# map True to canonical default path,False to "" and Path to str
"""Set default paths for where to save output files."""
# map True to canonical default path, False to "" and Path to str
for key, val, default_path in (
("write_force_constants", self.write_force_constants, "force_constants"),
("write_band_structure", self.write_band_structure, "band_structure.yaml"),
Expand Down
1 change: 1 addition & 0 deletions matcalc/relaxation.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class RelaxCalc(PropCalc):
def __init__(
self,
calculator: Calculator,
*,
optimizer: Optimizer | str = "FIRE",
max_steps: int = 500,
traj_file: str | None = None,
Expand Down
15 changes: 6 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
[build-system]
requires = ["oldest-supported-numpy", "setuptools>=58.0.3"]
build-backend = "setuptools.build_meta"

[project]
name = "matcalc"
authors = [
Expand Down Expand Up @@ -48,6 +44,10 @@ models = ["chgnet", "mace-torch", "matgl>=0.9.0"]
[tool.setuptools]
packages = ["matcalc"]

[build-system]
requires = ["oldest-supported-numpy", "setuptools>=58.0.3"]
build-backend = "setuptools.build_meta"

[tool.ruff]
target-version = "py39"
line-length = 120
Expand All @@ -59,15 +59,12 @@ ignore = [
"ANN101",
"ANN401",
"COM812", # trailing comma missing
"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
"EM101",
"EM102",
"FBT001",
"FBT002",
"ISC001",
"PLR", # pylint refactor
"PLR0913", # too many arguments
"PLW0603", # Using the global statement to update variables is discouraged
"PTH", # prefer Path to os.path
"SIM105", # Use contextlib.suppress(OSError) instead of try-except-pass
Expand All @@ -83,7 +80,7 @@ docstring-code-format = true
[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401"]
"tasks.py" = ["ANN", "D", "T203"]
"tests/*" = ["D", "INP001", "N802", "N803", "S101"]
"tests/*" = ["", "D", "INP001", "N802", "N803", "S101"]

[tool.pytest.ini_options]
addopts = "--durations=30 --quiet -rXs --color=yes -p no:warnings"
Expand Down
2 changes: 1 addition & 1 deletion tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def release_github(ctx): # noqa: ARG001


@task
def release(ctx, notest: bool = False) -> None:
def release(ctx, notest: bool = False) -> None: # noqa: FBT001, FBT002
ctx.run("rm -r dist build matcalc.egg-info", warn=True)
if not notest:
ctx.run("pytest tests")
Expand Down

0 comments on commit cae9d94

Please sign in to comment.