Skip to content

Commit

Permalink
fix ruff PERF401 errors
Browse files Browse the repository at this point in the history
  • Loading branch information
janosh committed Aug 3, 2023
1 parent 41399f0 commit a33ce34
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 22 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
exclude: ^(docs|.*test_files|tests)
exclude: ^(docs|test_files|tests)

ci:
autoupdate_schedule: monthly
Expand All @@ -8,7 +8,7 @@ ci:

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.281
rev: v0.0.282
hooks:
- id: ruff
args: [--fix, --ignore, D]
Expand Down
13 changes: 5 additions & 8 deletions custodian/vasp/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -778,14 +778,11 @@ def __init__(
self.gamma_vasp_cmd = tuple(gamma_vasp_cmd) if gamma_vasp_cmd else None
self.auto_continue = auto_continue
self.settings_override = settings_override
self.neb_dirs = [] # 00, 01, etc.
self.neb_sub = [] # 01, 02, etc.

for path in os.listdir("."):
if os.path.isdir(path) and path.isdigit():
self.neb_dirs.append(path)
self.neb_dirs = sorted(self.neb_dirs)
self.neb_sub = self.neb_dirs[1:-1]

self.neb_dirs = sorted( # 00, 01, etc.
path for path in os.listdir(".") if os.path.isdir(path) and path.isdigit()
)
self.neb_sub = self.neb_dirs[1:-1] # 01, 02, etc.

def setup(self):
"""
Expand Down
5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ ignore = [
"PD011", # pandas-use-of-dot-values
"PD901", # pandas-df-variable-name
"PERF203", # try-except-in-loop
"PERF401", # manual-list-comprehension (TODO fix these or wait for autofix)
"PLR", # pylint refactor
"PLW2901", # Outer for loop variable overwritten by inner assignment target
"PT013", # pytest-incorrect-pytest-import
Expand Down Expand Up @@ -82,12 +81,12 @@ exclude_lines = [
"@deprecated",
"def __repr__",
"if 0:",
"if TYPE_CHECKING:",
"if __name__ == .__main__.:",
"if self.debug:",
"if settings.DEBUG",
"input",
"pragma: no cover",
"raise AssertionError",
"raise NotImplementedError",
"input",
"if TYPE_CHECKING:"
]
13 changes: 4 additions & 9 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,15 @@ def test(ctx):

@task
def set_ver(ctx):
lines = []
with open("custodian/__init__.py") as file:
for line in file:
if "__version__" in line:
lines.append(f'__version__ = "{NEW_VER}"')
else:
lines.append(line.rstrip())
lines = [f'__version__ = "{NEW_VER}"' if "__version__" in line else line.rstrip() for line in file]

with open("custodian/__init__.py", "w") as file:
file.write("\n".join(lines) + "\n")

lines = []
with open("setup.py") as file:
for line in file:
lines.append(re.sub(r"version=([^,]+),", f'version="{NEW_VER}",', line.rstrip()))
lines = [re.sub(r"version=([^,]+),", f'version="{NEW_VER}",', line.rstrip()) for line in file]

with open("setup.py", "w") as file:
file.write("\n".join(lines) + "\n")

Expand Down

0 comments on commit a33ce34

Please sign in to comment.