Skip to content

Commit

Permalink
Fix ruff.
Browse files Browse the repository at this point in the history
  • Loading branch information
shyuep committed Oct 14, 2024
1 parent 8cbd590 commit 2af34f4
Show file tree
Hide file tree
Showing 20 changed files with 31 additions and 34 deletions.
3 changes: 2 additions & 1 deletion tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
from glob import glob

import requests
from custodian import __version__ as CURRENT_VER
from invoke import task
from monty.os import cd

from custodian import __version__ as CURRENT_VER

NEW_VER = datetime.datetime.now(tz=datetime.UTC).strftime("%Y.%-m.%-d")


Expand Down
1 change: 1 addition & 0 deletions tests/ansible/test_interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from typing import Any

import pytest

from custodian.ansible.actions import FileActions
from custodian.ansible.interpreter import Modder

Expand Down
6 changes: 3 additions & 3 deletions tests/cp2k/test_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
import warnings
from glob import glob

from pymatgen.io.cp2k.inputs import Keyword, KeywordList
from pymatgen.io.cp2k.sets import StaticSet

from custodian.cp2k.handlers import (
AbortHandler,
FrozenJobErrorHandler,
Expand All @@ -17,9 +20,6 @@
get_conv,
)
from custodian.cp2k.interpreter import Cp2kModder
from pymatgen.io.cp2k.inputs import Keyword, KeywordList
from pymatgen.io.cp2k.sets import StaticSet

from tests.conftest import TEST_FILES

TEST_FILES_DIR = f"{TEST_FILES}/cp2k"
Expand Down
3 changes: 1 addition & 2 deletions tests/cp2k/test_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
from glob import glob
from pathlib import Path

from custodian import Custodian
from custodian.cp2k.jobs import Cp2kJob

from custodian.custodian import Custodian
from tests.conftest import TEST_FILES

MODULE_DIR = Path(__file__).resolve().parent
Expand Down
1 change: 0 additions & 1 deletion tests/feff/test_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from glob import glob

from custodian.feff.handlers import UnconvergedErrorHandler

from tests.conftest import TEST_FILES

__author__ = "Chen Zheng"
Expand Down
4 changes: 2 additions & 2 deletions tests/feff/test_jobs.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import os

from custodian.feff.jobs import FeffJob
from monty.os import cd
from monty.tempfile import ScratchDir
from pymatgen.io.feff.inputs import Atoms, Tags

from custodian.feff.jobs import FeffJob
from tests.conftest import TEST_FILES

__author__ = "Chen Zheng"
Expand All @@ -20,7 +20,7 @@
def test_as_from_dict() -> None:
f = FeffJob("hello")
f2 = FeffJob.from_dict(f.as_dict())
assert type(f) == type(f2)
assert isinstance(f, FeffJob)
assert f2.feff_cmd == "hello"


Expand Down
1 change: 0 additions & 1 deletion tests/gaussian/test_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from unittest import TestCase

from custodian.gaussian.handlers import GaussianErrorHandler, WallTimeErrorHandler

from tests.conftest import TEST_FILES

__author__ = "Rasha Atwi"
Expand Down
1 change: 0 additions & 1 deletion tests/gaussian/test_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from unittest import TestCase

from custodian.gaussian.jobs import GaussianJob

from tests.conftest import TEST_FILES

__author__ = "Rasha Atwi"
Expand Down
1 change: 0 additions & 1 deletion tests/lobster/test_handlers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os

from custodian.lobster.handlers import ChargeSpillingValidator, EnoughBandsValidator, LobsterFilesValidator

from tests.conftest import TEST_FILES

test_files_lobster = f"{TEST_FILES}/lobster/lobsterouts"
Expand Down
4 changes: 2 additions & 2 deletions tests/lobster/test_jobs.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import os
import shutil

from custodian.lobster.jobs import LobsterJob
from monty.os import cd
from monty.tempfile import ScratchDir

from custodian.lobster.jobs import LobsterJob
from tests.conftest import TEST_FILES

test_files_lobster2 = f"{TEST_FILES}/lobster/lobsterins"
Expand Down Expand Up @@ -63,7 +63,7 @@ class TestLobsterJob:
def test_as_from_dict(self) -> None:
v = LobsterJob(lobster_cmd="hello")
v2 = LobsterJob.from_dict(v.as_dict())
assert type(v2) == type(v)
assert isinstance(v2, LobsterJob)
assert v2.lobster_cmd == "hello"

def test_setup(self) -> None:
Expand Down
1 change: 0 additions & 1 deletion tests/nwchem/test_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from glob import glob

from custodian.nwchem.handlers import NwchemErrorHandler

from tests.conftest import TEST_FILES

__author__ = "shyuepingong"
Expand Down
2 changes: 1 addition & 1 deletion tests/qchem/test_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import unittest
from unittest import TestCase

from custodian.qchem.handlers import QChemErrorHandler
from pymatgen.io.qchem.inputs import QCInput

from custodian.qchem.handlers import QChemErrorHandler
from tests.conftest import TEST_FILES

try:
Expand Down
4 changes: 2 additions & 2 deletions tests/qchem/test_job_handler_interaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import unittest
from unittest import TestCase

from custodian.qchem.handlers import QChemErrorHandler
from custodian.qchem.jobs import QCJob
from pymatgen.io.qchem.inputs import QCInput

from custodian.qchem.handlers import QChemErrorHandler
from custodian.qchem.jobs import QCJob
from tests.conftest import TEST_FILES

try:
Expand Down
2 changes: 1 addition & 1 deletion tests/qchem/test_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
from unittest.mock import patch

import pytest
from custodian.qchem.jobs import QCJob
from pymatgen.io.qchem.inputs import QCInput

from custodian.qchem.jobs import QCJob
from tests.conftest import TEST_FILES

try:
Expand Down
3 changes: 2 additions & 1 deletion tests/test_custodian.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from glob import glob

import pytest
from ruamel.yaml import YAML

from custodian.custodian import (
Custodian,
ErrorHandler,
Expand All @@ -17,7 +19,6 @@
ValidationError,
Validator,
)
from ruamel.yaml import YAML


class ExitCodeJob(Job):
Expand Down
14 changes: 7 additions & 7 deletions tests/vasp/test_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
from glob import glob

import pytest
from monty.os.path import zpath
from pymatgen.io.vasp.inputs import Incar, Kpoints, Structure, VaspInput
from pymatgen.util.testing import PymatgenTest

from custodian.utils import tracked_lru_cache
from custodian.vasp.handlers import (
AliasingErrorHandler,
Expand All @@ -25,10 +29,6 @@
VaspErrorHandler,
WalltimeHandler,
)
from monty.os.path import zpath
from pymatgen.io.vasp.inputs import Incar, Kpoints, Structure, VaspInput
from pymatgen.util.testing import PymatgenTest

from tests.conftest import TEST_FILES

__author__ = "Shyue Ping Ong, Stephen Dacek, Janosh Riebesell"
Expand Down Expand Up @@ -301,7 +301,7 @@ def test_coef(self) -> None:
def test_as_from_dict(self) -> None:
handler = VaspErrorHandler("random_name")
h2 = VaspErrorHandler.from_dict(handler.as_dict())
assert type(h2) == type(handler)
assert isinstance(h2, VaspErrorHandler)
assert h2.output_filename == "random_name"

def test_pssyevx_pdsyevx(self) -> None:
Expand Down Expand Up @@ -742,7 +742,7 @@ def test_amin(self) -> None:
def test_as_from_dict(self) -> None:
handler = UnconvergedErrorHandler("random_name.xml")
h2 = UnconvergedErrorHandler.from_dict(handler.as_dict())
assert type(h2) == UnconvergedErrorHandler
assert isinstance(h2, UnconvergedErrorHandler)
assert h2.output_filename == "random_name.xml"

def test_correct_normal_with_condition(self) -> None:
Expand Down Expand Up @@ -1164,5 +1164,5 @@ def test_correct(self) -> None:
def test_as_from_dict(self) -> None:
handler = NonConvergingErrorHandler("OSZICAR_random")
h2 = NonConvergingErrorHandler.from_dict(handler.as_dict())
assert type(h2) == type(handler)
assert isinstance(h2, NonConvergingErrorHandler)
assert h2.output_filename == "OSZICAR_random"
4 changes: 2 additions & 2 deletions tests/vasp/test_io.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import pytest
from custodian.utils import tracked_lru_cache
from custodian.vasp.io import load_outcar, load_vasprun
from monty.os.path import zpath

from custodian.utils import tracked_lru_cache
from custodian.vasp.io import load_outcar, load_vasprun
from tests.conftest import TEST_FILES


Expand Down
6 changes: 3 additions & 3 deletions tests/vasp/test_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

import pymatgen
import pytest
from custodian.vasp.jobs import GenerateVaspInputJob, VaspJob, VaspNEBJob
from monty.os import cd
from monty.tempfile import ScratchDir
from pymatgen.io.vasp import Incar, Kpoints, Poscar

from custodian.vasp.jobs import GenerateVaspInputJob, VaspJob, VaspNEBJob
from tests.conftest import TEST_FILES

pymatgen.core.SETTINGS["PMG_VASP_PSP_DIR"] = TEST_FILES
Expand All @@ -19,7 +19,7 @@ class TestVaspJob:
def test_as_from_dict(self) -> None:
v = VaspJob(["hello"])
v2 = VaspJob.from_dict(v.as_dict())
assert type(v2) == type(v)
assert isinstance(v2, VaspJob)
assert v2.vasp_cmd == ("hello",)

def test_setup(self) -> None:
Expand Down Expand Up @@ -103,7 +103,7 @@ class TestVaspNEBJob:
def test_as_from_dict(self) -> None:
v = VaspNEBJob(["hello"])
v2 = VaspNEBJob.from_dict(v.as_dict())
assert type(v2) == type(v)
assert isinstance(v2, VaspNEBJob)
assert v2.vasp_cmd == ("hello",)

def test_setup(self) -> None:
Expand Down
2 changes: 1 addition & 1 deletion tests/vasp/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

import numpy as np
import pytest
from custodian.vasp.utils import _estimate_num_k_points_from_kspacing, increase_k_point_density
from monty.os.path import zpath
from pymatgen.core import Lattice, Structure
from pymatgen.io.vasp import Kpoints
from pymatgen.util.testing import PymatgenTest

from custodian.vasp.utils import _estimate_num_k_points_from_kspacing, increase_k_point_density
from tests.conftest import TEST_FILES


Expand Down
2 changes: 1 addition & 1 deletion tests/vasp/test_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import shutil

import pytest
from custodian.vasp.validators import VaspAECCARValidator, VaspFilesValidator, VaspNpTMDValidator, VasprunXMLValidator

from custodian.vasp.validators import VaspAECCARValidator, VaspFilesValidator, VaspNpTMDValidator, VasprunXMLValidator
from tests.conftest import TEST_FILES


Expand Down

0 comments on commit 2af34f4

Please sign in to comment.