Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix failing ruff PT001 on master #4003

Merged
merged 3 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ci:

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.7
rev: v0.6.0
hooks:
- id: ruff
args: [--fix, --unsafe-fixes]
Expand Down Expand Up @@ -65,6 +65,6 @@ repos:
args: [--drop-empty-cells, --keep-output]

- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.375
rev: v1.1.376
hooks:
- id: pyright
5 changes: 2 additions & 3 deletions tests/core/test_xcfunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,11 @@ def test_pickle_serialize(self):
# Test if object can be serialized with Pickle
self.serialize_with_pickle(self.ixc_11)

@pytest.mark.skip()
@pytest.mark.skip(reason="TODO:")
def test_msonable(self):
# Test if object supports MSONable
# TODO
self.ixc_11.x.as_dict()
self.assertMSONable(self.ixc_11)
self.assert_msonable(self.ixc_11)

def test_from(self):
# GGA-PBE from ixc given in abinit-libxc mode
Expand Down
30 changes: 15 additions & 15 deletions tests/entries/test_mixing_scheme.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def all_entries(self):
return self.gga_entries + self.scan_entries


@pytest.fixture()
@pytest.fixture
def mixing_scheme_no_compat():
"""Get an instance of MaterialsProjectDFTMixingScheme with no additional
compatibility schemes (e.g., compat_1=None). Used by most of the tests where
Expand Down Expand Up @@ -205,7 +205,7 @@ def mixing_scheme_no_compat():
)


@pytest.fixture()
@pytest.fixture
def ms_complete():
"""Mixing state where we have R2SCAN for all GGA."""
gga_entries = [
Expand Down Expand Up @@ -370,7 +370,7 @@ def ms_complete():
return MixingState(gga_entries, scan_entries, mixing_state)


@pytest.fixture()
@pytest.fixture
def ms_scan_only(ms_complete):
"""Mixing state with only R2SCAN entries."""
gga_entries = []
Expand All @@ -391,7 +391,7 @@ def ms_scan_only(ms_complete):
return MixingState(gga_entries, scan_entries, mixing_state)


@pytest.fixture()
@pytest.fixture
def ms_gga_only(ms_complete):
"""Mixing state with only GGA entries."""
gga_entries = ms_complete.gga_entries
Expand All @@ -412,7 +412,7 @@ def ms_gga_only(ms_complete):
return MixingState(gga_entries, scan_entries, mixing_state)


@pytest.fixture()
@pytest.fixture
def ms_gga_1_scan(ms_complete):
"""
Mixing state with all GGA entries and one R2SCAN, corresponding to the GGA
Expand All @@ -434,7 +434,7 @@ def ms_gga_1_scan(ms_complete):
return MixingState(gga_entries, scan_entries, mixing_state)


@pytest.fixture()
@pytest.fixture
def ms_gga_1_scan_novel(ms_complete):
"""
Mixing state with all GGA entries and 1 R2SCAN, corresponding to a composition
Expand Down Expand Up @@ -464,7 +464,7 @@ def ms_gga_1_scan_novel(ms_complete):
return MixingState(gga_entries, scan_entries, mixing_state)


@pytest.fixture()
@pytest.fixture
def ms_gga_2_scan_same(ms_complete):
"""
Mixing state with all GGA entries and 2 R2SCAN, corresponding to the GGA
Expand All @@ -486,7 +486,7 @@ def ms_gga_2_scan_same(ms_complete):
return MixingState(gga_entries, scan_entries, mixing_state)


@pytest.fixture()
@pytest.fixture
def ms_gga_2_scan_diff_match(ms_complete):
"""
Mixing state with all GGA entries and 2 R2SCAN entries corresponding to
Expand All @@ -510,7 +510,7 @@ def ms_gga_2_scan_diff_match(ms_complete):
return MixingState(gga_entries, scan_entries, mixing_state)


@pytest.fixture()
@pytest.fixture
def ms_gga_2_scan_diff_no_match(ms_complete):
"""
Mixing state with all GGA entries and 2 R2SCAN, corresponding to the GGA
Expand Down Expand Up @@ -552,7 +552,7 @@ def ms_gga_2_scan_diff_no_match(ms_complete):
return MixingState(gga_entries, scan_entries, mixing_state)


@pytest.fixture()
@pytest.fixture
def ms_all_gga_scan_gs(ms_complete):
"""
Mixing state with all GGA entries and R2SCAN entries corresponding to all GGA
Expand All @@ -576,7 +576,7 @@ def ms_all_gga_scan_gs(ms_complete):
return MixingState(gga_entries, scan_entries, mixing_state)


@pytest.fixture()
@pytest.fixture
def ms_all_gga_scan_gs_plus_novel(ms_all_gga_scan_gs):
"""
Mixing state with all GGA entries and R2SCAN entries corresponding to all GGA
Expand Down Expand Up @@ -617,7 +617,7 @@ def ms_all_gga_scan_gs_plus_novel(ms_all_gga_scan_gs):
return MixingState(gga_entries, scan_entries, mixing_state)


@pytest.fixture()
@pytest.fixture
def ms_all_scan_novel(ms_complete):
"""
Mixing state with all GGA entries and all R2SCAN, with an additional unstable
Expand Down Expand Up @@ -658,7 +658,7 @@ def ms_all_scan_novel(ms_complete):
return MixingState(gga_entries, scan_entries, mixing_state)


@pytest.fixture()
@pytest.fixture
def ms_incomplete_gga_all_scan(ms_complete):
"""Mixing state with an incomplete GGA phase diagram."""
gga_entries = [entry for entry in ms_complete.gga_entries if entry.reduced_formula != "Sn"]
Expand All @@ -678,7 +678,7 @@ def ms_incomplete_gga_all_scan(ms_complete):
return MixingState(gga_entries, scan_entries, mixing_state)


@pytest.fixture()
@pytest.fixture
def ms_scan_chemsys_superset(ms_complete):
"""
Mixing state where we have R2SCAN for all GGA, and there is an additional R2SCAN
Expand Down Expand Up @@ -709,7 +709,7 @@ def ms_scan_chemsys_superset(ms_complete):
return MixingState(gga_entries, scan_entries, mixing_state)


@pytest.fixture()
@pytest.fixture
def ms_complete_duplicate_structs(ms_complete):
"""
Mixing state where we have R2SCAN for all GGA, plus extra entries that duplicate
Expand Down
22 changes: 11 additions & 11 deletions tests/io/aims/test_aims_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
parser_file_dir = Path(__file__).parent / "parser_checks"


@pytest.fixture()
@pytest.fixture
def default_chunk():
lines = ["TEST", "A", "TEST", "| Number of atoms: 200 atoms"]
return AimsOutChunk(lines)
Expand All @@ -50,7 +50,7 @@ def test_search_parse_scalar(default_chunk):
assert default_chunk.parse_scalar("n_electrons") is None


@pytest.fixture()
@pytest.fixture
def empty_header_chunk():
return AimsOutHeaderChunk([])

Expand Down Expand Up @@ -89,7 +89,7 @@ def test_default_header_k_point_weights(empty_header_chunk):
assert empty_header_chunk.k_point_weights is None


@pytest.fixture()
@pytest.fixture
def initial_lattice():
return np.array(
[
Expand All @@ -100,7 +100,7 @@ def initial_lattice():
)


@pytest.fixture()
@pytest.fixture
def header_chunk():
with gzip.open(f"{parser_file_dir}/header_chunk.out.gz", mode="rt") as hc_file:
lines = hc_file.readlines()
Expand Down Expand Up @@ -155,7 +155,7 @@ def test_header_n_k_points(header_chunk):
assert header_chunk.n_k_points == 8


@pytest.fixture()
@pytest.fixture
def k_points():
return np.array(
[
Expand Down Expand Up @@ -203,7 +203,7 @@ def test_header_header_summary(header_chunk, k_points):
assert val == header_summary[key]


@pytest.fixture()
@pytest.fixture
def empty_calc_chunk(header_chunk):
return AimsOutCalcChunk([], header_chunk)

Expand Down Expand Up @@ -288,7 +288,7 @@ def test_default_calc_converged(empty_calc_chunk):
assert not empty_calc_chunk.converged


@pytest.fixture()
@pytest.fixture
def calc_chunk(header_chunk):
with gzip.open(f"{parser_file_dir}/calc_chunk.out.gz", mode="rt") as file:
lines = file.readlines()
Expand All @@ -298,7 +298,7 @@ def calc_chunk(header_chunk):
return AimsOutCalcChunk(lines, header_chunk)


@pytest.fixture()
@pytest.fixture
def numerical_stress_chunk(header_chunk):
with gzip.open(f"{parser_file_dir}/numerical_stress.out.gz", mode="rt") as file:
lines = file.readlines()
Expand Down Expand Up @@ -419,7 +419,7 @@ def test_calc_hirshfeld_dipole(calc_chunk):
assert calc_chunk.hirshfeld_dipole is None


@pytest.fixture()
@pytest.fixture
def molecular_header_chunk():
with gzip.open(f"{parser_file_dir}/molecular_header_chunk.out.gz", mode="rt") as file:
lines = file.readlines()
Expand Down Expand Up @@ -451,7 +451,7 @@ def test_molecular_header_initial_structure(molecular_header_chunk, molecular_po
)


@pytest.fixture()
@pytest.fixture
def molecular_calc_chunk(molecular_header_chunk):
with gzip.open(f"{parser_file_dir}/molecular_calc_chunk.out.gz", mode="rt") as file:
lines = file.readlines()
Expand All @@ -461,7 +461,7 @@ def molecular_calc_chunk(molecular_header_chunk):
return AimsOutCalcChunk(lines, molecular_header_chunk)


@pytest.fixture()
@pytest.fixture
def molecular_positions():
return np.array([[-0.00191785, -0.00243279, 0], [0.97071531, -0.00756333, 0], [-0.25039746, 0.93789612, 0]])

Expand Down
2 changes: 1 addition & 1 deletion tests/io/qchem/test_outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def _test_property(self, key, single_outs, multi_outs):
else:
assert_allclose(sub_output.data.get(key), multi_job_dict[filename][idx].get(key), atol=1e-6)

@pytest.mark.skip() # self._test_property(key, single_outs, multi_outs) fails with
@pytest.mark.skip # self._test_property(key, single_outs, multi_outs) fails with
# ValueError: The truth value of an array with more than one element is ambiguous
@pytest.mark.skipif(openbabel is None, reason="OpenBabel not installed.")
def test_all(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/io/test_openff.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
pybel = pytest.importorskip("openbabel.pybel")


@pytest.fixture()
@pytest.fixture
def mol_files():
return {
"CCO_xyz": f"{TEST_DIR}/CCO.xyz",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from pytest import MonkeyPatch


@pytest.fixture()
@pytest.fixture
def cd_tmp_path(tmp_path: Path, monkeypatch: MonkeyPatch):
monkeypatch.chdir(tmp_path)
return tmp_path
Expand Down