Skip to content

Commit

Permalink
ruff unignore FURB + auto-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
janosh committed Aug 22, 2024
1 parent f293567 commit 24cbef2
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 27 deletions.
34 changes: 17 additions & 17 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -178,23 +178,22 @@ output-format = "concise"
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)
"PTH", # Prefer pathlib over os.path
"SLF", # Access "private" class members
"T20", # Check for print/pprint
"TD", # TODO tags related
"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
"G", # Validate logging format strings
"INP", # Ban PEP-420 implicit namespace packages
"N", # PEP8-naming (many var/arg names are intended)
"PTH", # Prefer pathlib over os.path
"SLF", # Access "private" class members
"T20", # Check for print/pprint
"TD", # TODO tags related

# Single rules
"B023", # Function definition does not bind loop variable
Expand All @@ -213,6 +212,7 @@ ignore = [
"PLR0912", # Too many branches
"PLR0913", # Too many arguments
"PLR0915", # Too many statements
"PLR1702", # Too many nested blocks
"PLR2004", # Magic-value-comparison TODO fix these
"PLW2901", # Outer for loop variable overwritten by inner assignment target
"PT013", # Incorrect import of pytest
Expand Down
5 changes: 1 addition & 4 deletions src/pymatgen/analysis/chemenv/utils/scripts_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,7 @@ def draw_cg(
faces = cg.faces(neighbors)
edges = cg.edges(neighbors)
symbol = next(iter(site.species)).symbol
if faces_color_override:
color = faces_color_override
else:
color = [float(i) / 255 for i in vis.el_color_mapping[symbol]]
color = faces_color_override or [float(i) / 255 for i in vis.el_color_mapping[symbol]]
vis.add_faces(faces, color, opacity=0.4)
vis.add_edges(edges)
if show_perfect:
Expand Down
6 changes: 3 additions & 3 deletions src/pymatgen/analysis/phase_diagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -3036,7 +3036,7 @@ def get_marker_props(coords, entries):
for el, axis in zip(self._pd.elements, range(self._dim), strict=True):
_cartesian_positions = [x, y, z]
_cartesian_positions[axis].append(entry.composition[el])
label += f"<br> {el}: {round(entry.composition[el]/total_sum_el, 6)}"
label += f"<br> {el}: {round(entry.composition[el] / total_sum_el, 6)}"
elif self._dim == 3 and self.ternary_style == "3d":
x.append(coord[0])
y.append(coord[1])
Expand All @@ -3047,7 +3047,7 @@ def get_marker_props(coords, entries):
entry.composition[el] for el, _axis in zip(self._pd.elements, range(self._dim), strict=True)
)
for el, _axis in zip(self._pd.elements, range(self._dim), strict=True):
label += f"<br> {el}: {round(entry.composition[el]/total_sum_el, 6)}"
label += f"<br> {el}: {round(entry.composition[el] / total_sum_el, 6)}"
elif self._dim == 4:
x.append(coord[0])
y.append(coord[1])
Expand All @@ -3058,7 +3058,7 @@ def get_marker_props(coords, entries):
entry.composition[el] for el, _axis in zip(self._pd.elements, range(self._dim), strict=True)
)
for el, _axis in zip(self._pd.elements, range(self._dim), strict=True):
label += f"<br> {el}: {round(entry.composition[el]/total_sum_el, 6)}"
label += f"<br> {el}: {round(entry.composition[el] / total_sum_el, 6)}"
else:
x.append(coord[0])
y.append(coord[1])
Expand Down
2 changes: 1 addition & 1 deletion tests/analysis/test_adsorption.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def test_generate_adsorption_structures(self):
assert len(structures) == 4
sites = self.asf_111.find_adsorption_sites()
# Check repeat functionality
assert len(site.properties["surface_properties"] != "adsorbate" for site in structures[0]) == 4 * len(
assert sum(site.properties["surface_properties"] != "adsorbate" for site in structures[0]) == 4 * len(
self.asf_111.slab
)
for n, structure in enumerate(structures):
Expand Down
4 changes: 2 additions & 2 deletions tests/io/vasp/test_sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ def test_sets_changed(self):
"PBE54Base.yaml": "cdffe123eca8b19354554b60a7f8de9b8776caac9e1da2bd2a0516b7bfac8634",
}

for input_set in hashes:
assert hashes[input_set] == known_hashes[input_set], f"{input_set=}\n{msg}"
for input_set, hash_str in hashes.items():
assert hash_str == known_hashes[input_set], f"{input_set=}\n{msg}"


class TestVaspInputSet(PymatgenTest):
Expand Down

0 comments on commit 24cbef2

Please sign in to comment.