Skip to content

Commit

Permalink
Fix lints (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasturcani authored Jul 4, 2024
1 parent 8e71823 commit e9cfb2c
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 50 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
python-version: "3.11"
cache: "pip"
- run: "pip install '.[dev]'"
- run: ruff .
- run: ruff check .
mypy:
runs-on: ubuntu-22.04
steps:
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ maintainers = [
{ name = "Lukas Turcani", email = "[email protected]" },
]
dependencies = [
"rdkit",
"numpy==1.26.4", # remove pin when ecosystem updates to 2.0
"rdkit==2023.9.5", # remove pin when type issues are resolved
"stk",
"networkx",
]
Expand Down
5 changes: 1 addition & 4 deletions src/stko/_internal/calculators/extractors/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,4 @@ def check_line(line: str, option: str, options_dict: dict[str, str]) -> bool:
Returns ``True`` if the desired string is present.
"""
if options_dict[option] in line:
return True

return False
return options_dict[option] in line
4 changes: 2 additions & 2 deletions src/stko/_internal/calculators/orca_calculators.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,13 @@ def _run_orca( # noqa: PLR0913
with out_file.open("w") as f:
# Note that sp.call will hold the program until
# completion of the calculation.
sp.call(
sp.call( # noqa: S602
cmd,
stdin=sp.PIPE,
stdout=f,
stderr=sp.PIPE,
# Shell is required to run complex arguments.
shell=True, # noqa: S602
shell=True,
)
self._check_outcome(out_file)
if self._discard_output:
Expand Down
4 changes: 2 additions & 2 deletions src/stko/_internal/calculators/xtb_calculators.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,13 +323,13 @@ def _run_xtb(
with out_file.open("w") as f:
# Note that sp.call will hold the program until
# completion of the calculation.
sp.call(
sp.call( # noqa: S602
cmd,
stdin=sp.PIPE,
stdout=f,
stderr=sp.PIPE,
# Shell is required to run complex arguments.
shell=True, # noqa: S602
shell=True,
)
finally:
os.chdir(init_dir)
Expand Down
8 changes: 4 additions & 4 deletions src/stko/_internal/optimizers/collapser.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,10 +661,10 @@ def _output_top_lines(self) -> str:

def _plot_progess( # noqa: PLR0913
self,
steps: abc.Iterable,
maxds: abc.Iterable,
spots: abc.Iterable,
npots: abc.Iterable,
steps: list,
maxds: list,
spots: list,
npots: list,
output_dir: Path,
) -> None:
fig, ax = plt.subplots(figsize=(8, 5))
Expand Down
20 changes: 12 additions & 8 deletions src/stko/_internal/optimizers/gulp.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import shutil
import subprocess as sp
import uuid
import warnings
from pathlib import Path

import stk
Expand Down Expand Up @@ -547,12 +548,15 @@ def assign_FF(self, mol: stk.Molecule) -> None: # noqa: N802
The molecule to be optimized.
"""
FutureWarning(
"We have found some minor discrepancies in this "
"assignment algorithm, which is based off rdkit code. "
"Changes should come soon. This UFF optimisation should "
" not be your final step! Due to this, some tests in "
"test_uff_assign_ff.py have been muted."
warnings.warn(
FutureWarning(
"We have found some minor discrepancies in this "
"assignment algorithm, which is based off rdkit code. "
"Changes should come soon. This UFF optimisation should "
" not be your final step! Due to this, some tests in "
"test_uff_assign_ff.py have been muted."
),
stacklevel=2,
)

metal_atoms = get_metal_atoms(mol)
Expand Down Expand Up @@ -595,13 +599,13 @@ def _run_gulp(self, in_file: Path, out_file: Path) -> None:
with out_file.open("w") as f:
# Note that sp.call will hold the program until completion
# of the calculation.
sp.call(
sp.call( # noqa: S602
cmd,
stdin=sp.PIPE,
stdout=f,
stderr=sp.PIPE,
# Shell is required to run complex arguments.
shell=True, # noqa: S602
shell=True,
)

def extract_final_energy(self, out_file: Path) -> float:
Expand Down
21 changes: 9 additions & 12 deletions src/stko/_internal/optimizers/macromodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ def _run_bmin(self, mol: stk.Molecule, run_name: str) -> None:

incomplete = True
while incomplete:
process = sp.Popen(
opt_cmd, # noqa: S603
process = sp.Popen( # noqa: S603
opt_cmd,
stdout=sp.PIPE,
stderr=sp.STDOUT,
universal_newlines=True,
Expand Down Expand Up @@ -227,8 +227,8 @@ def _kill_bmin(self, run_name: str) -> None:

incomplete = True
while incomplete:
out = sp.run(
cmd, # noqa: S603
out = sp.run( # noqa: S603
cmd,
stdout=sp.PIPE,
stderr=sp.STDOUT,
text=True,
Expand All @@ -248,8 +248,8 @@ def _kill_bmin(self, run_name: str) -> None:
output = name
start = time.time()
while name in output:
output = sp.run(
cmd, # noqa: S603
output = sp.run( # noqa: S603
cmd,
stdout=sp.PIPE,
stderr=sp.STDOUT,
text=True,
Expand Down Expand Up @@ -303,10 +303,7 @@ def _license_found(
with Path(f"{run_name}.log").open() as f:
log_file = f.read()

if "Could not check out a license for mmlibs" in log_file:
return False

return True
return "Could not check out a license for mmlibs" not in log_file

@staticmethod
def _get_com_line( # noqa: PLR0913
Expand Down Expand Up @@ -344,8 +341,8 @@ def _run_structconvert(self, input_path: Path, output_path: Path) -> None:
while incomplete:
# Execute the file conversion.
try:
convrt_return = sp.run(
convrt_cmd, # noqa: S603
convrt_return = sp.run( # noqa: S603
convrt_cmd,
stdout=sp.PIPE,
stderr=sp.STDOUT,
text=True,
Expand Down
10 changes: 2 additions & 8 deletions src/stko/_internal/optimizers/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,7 @@ def has_h_atom(bond: stk.Bond) -> bool:
"""
if bond.get_atom1().get_atomic_number() == 1:
return True
if bond.get_atom2().get_atomic_number() == 1:
return True

return False
return bond.get_atom2().get_atomic_number() == 1


def has_metal_atom(bond: stk.Bond, metal_atoms: list[stk.Atom]) -> bool:
Expand All @@ -328,10 +325,7 @@ def has_metal_atom(bond: stk.Bond, metal_atoms: list[stk.Atom]) -> bool:
"""
if bond.get_atom1() in metal_atoms:
return True
if bond.get_atom2() in metal_atoms:
return True

return False
return bond.get_atom2() in metal_atoms


def metal_atomic_numbers() -> abc.Iterable:
Expand Down
16 changes: 8 additions & 8 deletions src/stko/_internal/optimizers/xtb.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,13 +376,13 @@ def _run_xtb(self, xyz: str, out_file: Path | str) -> None:
with out_file.open("w") as f:
# Note that sp.call will hold the program until completion
# of the calculation.
sp.call(
sp.call( # noqa: S602
cmd,
stdin=sp.PIPE,
stdout=f,
stderr=sp.PIPE,
# Shell is required to run complex arguments.
shell=True, # noqa: S602
shell=True,
)

def _write_detailed_control(self) -> None:
Expand Down Expand Up @@ -804,13 +804,13 @@ def _run_crest(self, xyz: str, out_file: Path | str) -> None:
with out_file.open("w") as f:
# Note that sp.call will hold the program until completion
# of the calculation.
sp.call(
sp.call( # noqa: S602
cmd,
stdin=sp.PIPE,
stdout=f,
stderr=sp.PIPE,
# Shell is required to run complex arguments.
shell=True, # noqa: S602
shell=True,
)

def _run_optimization(
Expand Down Expand Up @@ -1050,13 +1050,13 @@ def _run_xtb(self, xyz: str, out_file: Path | str) -> None:
with out_file.open("w") as f:
# Note that sp.call will hold the program until completion
# of the calculation.
sp.call(
sp.call( # noqa: S602
cmd,
stdin=sp.PIPE,
stdout=f,
stderr=sp.PIPE,
# Shell is required to run complex arguments.
shell=True, # noqa: S602
shell=True,
)

def _run_optimization(
Expand Down Expand Up @@ -1392,13 +1392,13 @@ def _run_crest(self, xyz: Path, out_file: Path) -> None:
with out_file.open("w") as f:
# Note that sp.call will hold the program until completion
# of the calculation.
sp.call(
sp.call( # noqa: S602
cmd,
stdin=sp.PIPE,
stdout=f,
stderr=sp.PIPE,
# Shell is required to run complex arguments.
shell=True, # noqa: S602
shell=True,
)

def _run_optimization(
Expand Down

0 comments on commit e9cfb2c

Please sign in to comment.