Skip to content
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 openfe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@


def _mute_timeseries(record):
return not "Warning on use of the timeseries module:" in record.msg
return "Warning on use of the timeseries module:" not in record.msg


def _mute_jax(record):
return not "****** PyMBAR will use 64-bit JAX! *******" in record.msg
return "****** PyMBAR will use 64-bit JAX! *******" not in record.msg


_mbar_log = logging.getLogger("pymbar.timeseries")
Expand Down
2 changes: 1 addition & 1 deletion openfe/protocols/openmm_afe/equil_binding_afe_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ def _validate_lambda_schedule(
lambda_components = [lambda_vdw, lambda_elec, lambda_restraints]
it = iter(lambda_components)
the_len = len(next(it))
if not all(len(l) == the_len for l in it):
if not all(len(lambda_comp) == the_len for lambda_comp in it):
errmsg = (
"Components elec, vdw, and restraints must have equal amount"
f" of lambda windows. Got {len(lambda_elec)} elec lambda"
Expand Down
2 changes: 1 addition & 1 deletion openfe/protocols/openmm_afe/equil_solvation_afe_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ def _validate_lambda_schedule(
lambda_components = [lambda_vdw, lambda_elec, lambda_restraints]
it = iter(lambda_components)
the_len = len(next(it))
if not all(len(l) == the_len for l in it):
if not all(len(lambda_comp) == the_len for lambda_comp in it):
errmsg = (
"Components elec, vdw, and restraints must have equal amount"
f" of lambda windows. Got {len(lambda_elec)} elec lambda"
Expand Down
4 changes: 2 additions & 2 deletions openfe/protocols/openmm_rfe/_rfe_utils/lambdaprotocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ def __init__(self, functions='default', windows=10, lambda_schedule=None):
else:
self.lambda_schedule = np.linspace(0., 1., windows)

if type(self.functions) == dict:
if isinstance(self.functions, dict):
self.type = 'user-defined'
elif type(self.functions) == str:
elif isinstance(self.functions, str):
self.functions = None # will be set later
self.type = functions

Expand Down
6 changes: 3 additions & 3 deletions openfe/setup/ligand_network_planning.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,8 @@ def load_orion_network(

with open(network_file, "r") as f:
network_lines = [
l.strip().split(" ") for l in f
if not l.startswith("#")
line.strip().split(" ") for line in f
if not line.startswith("#")
] # fmt: skip

names = []
Expand Down Expand Up @@ -451,7 +451,7 @@ def load_fepplus_network(
"""

with open(network_file, "r") as f:
network_lines = [l.split() for l in f.readlines()]
network_lines = [line.split() for line in f.readlines()]

names = []
for entry in network_lines:
Expand Down
3 changes: 2 additions & 1 deletion openfe/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# For details, see https://github.com/OpenFreeEnergy/openfe
import os
import pathlib
import urllib.error
import urllib.request
from importlib import resources

Expand Down Expand Up @@ -361,7 +362,7 @@ def am1bcc_ref_charges():

try:
urllib.request.urlopen("https://www.google.com")
except: # -no-cov-
except urllib.error.URLError: # -no-cov-
HAS_INTERNET = False
else:
HAS_INTERNET = True
Expand Down
8 changes: 4 additions & 4 deletions openfe/tests/setup/test_network_planning.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ def test_network_from_external(file_fixture, loader, request, benzene_modificati
network_file = request.getfixturevalue(file_fixture)

network = loader(
ligands=[l for l in benzene_modifications.values()],
ligands=[lig for lig in benzene_modifications.values()],
mapper=openfe.LomapAtomMapper(),
network_file=network_file,
)
Expand Down Expand Up @@ -721,7 +721,7 @@ def test_network_from_external(file_fixture, loader, request, benzene_modificati
)
def test_network_from_external_unknown_edge(file_fixture, loader, request, benzene_modifications):
network_file = request.getfixturevalue(file_fixture)
ligands = [l for l in benzene_modifications.values() if l.name != "phenol"]
ligands = [lig for lig in benzene_modifications.values() if lig.name != "phenol"]

with pytest.raises(KeyError, match="Invalid name"):
_ = loader(
Expand Down Expand Up @@ -750,7 +750,7 @@ def test_bad_orion_network(benzene_modifications, tmpdir):

with pytest.raises(KeyError, match="line does not match"):
_ = openfe.setup.ligand_network_planning.load_orion_network(
ligands=[l for l in benzene_modifications.values()],
ligands=[lig for lig in benzene_modifications.values()],
mapper=openfe.LomapAtomMapper(),
network_file="bad_orion_net.dat",
)
Expand All @@ -773,7 +773,7 @@ def test_bad_edges_network(benzene_modifications, tmpdir):

with pytest.raises(KeyError, match="line does not match"):
_ = openfe.setup.ligand_network_planning.load_fepplus_network(
ligands=[l for l in benzene_modifications.values()],
ligands=[lig for lig in benzene_modifications.values()],
mapper=openfe.LomapAtomMapper(),
network_file="bad_edges.edges",
)
2 changes: 1 addition & 1 deletion openfe/utils/logging_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ def __init__(self, string):
self.string = string

def filter(self, record):
return not self.string in record.msg
return self.string not in record.msg
2 changes: 1 addition & 1 deletion openfe/utils/system_probe.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ def log_system_probe(level=logging.DEBUG, paths: Optional[Iterable[os.PathLike]]
gpu = logging.getLogger(basename + ".gpu")
hostname = logging.getLogger(basename + ".hostname")
loggers = [base, gpu, hostname]
if any(l.isEnabledFor(level) for l in loggers):
if any(logger.isEnabledFor(level) for logger in loggers):
sysinfo = _probe_system(pl_paths)["system information"]
base.log(level, "SYSTEM CONFIG DETAILS:")
hostname.log(level, f"hostname: '{sysinfo['hostname']}'")
Expand Down
3 changes: 2 additions & 1 deletion openfecli/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import urllib.error
import urllib.request

try:
urllib.request.urlopen("https://www.google.com")
except: # -no-cov-
except urllib.error.URLError: # -no-cov-
HAS_INTERNET = False
else:
HAS_INTERNET = True
12 changes: 6 additions & 6 deletions openfecli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ def _should_configure_logger(logger: logging.Logger):
return False

# walk up the logging tree to see if any parent loggers are not default
l = logger
_logger = logger
while (
l.parent is not None # not the root logger
and l.level == logging.NOTSET # level not already set
and l.propagate # configured to use parent when not set
_logger.parent is not None # not the root logger
and _logger.level == logging.NOTSET # level not already set
and _logger.propagate # configured to use parent when not set
):
l = l.parent
_logger = _logger.parent

is_default = (l == logging.root and l.level == logging.WARNING) # fmt: skip
is_default = (_logger == logging.root and _logger.level == logging.WARNING) # fmt: skip

return is_default

Expand Down
5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,16 @@ line-length = 100

# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
lint.select = [
"E", # pycodestyle errors
"F", # Pyflakes
"I", # isort
"W", # pycodestyle warnings
# "E", # pycodestyle errors
# "C901" # mccabe complexity TODO: add this back in
# "UP", # TODO: add this in
]
lint.ignore = [
"E402", # module-level import not at top (conflicts w/ isort)
"E722", # bare excepts (TODO: we should fix these in a follow-up PR)
"E731", # lambda expressions (TODO: we should fix these)
"E501", # line length too long, resolve this for comments
"F401", # unused imports (TODO: we should fix these)
"F811",
"F841",
Expand Down