Skip to content

Commit

Permalink
flake fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
timryanb committed Jan 14, 2025
1 parent fe28c1a commit 537bc99
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/flake8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ jobs:
# use both MDO Lab standard config
- name: Code style (flake8)
run: |
pip install flake8==3.9.2
pip install flake8
wget https://raw.githubusercontent.com/mdolab/.github/master/.flake8 -O .flake8_mdolab
python -m flake8 mphys --append-config .flake8_mdolab --count --show-source --statistics
1 change: 0 additions & 1 deletion mphys/core/distributed_summer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import numpy as np
import openmdao.api as om

from mphys.core.distributed_converter import DistributedVariableDescription
Expand Down
2 changes: 1 addition & 1 deletion mphys/network/remote_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def _dump_json(self, remote_dict: dict, command: str):
if not os.path.isdir(save_dir):
try:
os.mkdir(save_dir)
except:
except OSError:
pass # may have been created by now, by a parallel server
if self._doing_derivative_evaluation(command):
filename = f"{save_dir}/{self.name}_{dict_type}_derivative{len(self.times_gradient)}.json"
Expand Down
6 changes: 3 additions & 3 deletions mphys/network/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def _load_the_model(self):
self.prob = om.Problem()
self.prob.model = self.get_om_group_function_pointer()
if self.ignore_setup_warnings:
with warnings.catch_warnings(record=True) as w:
with warnings.catch_warnings(record=True):
self.prob.setup(mode="rev")
else:
self.prob.setup(mode="rev")
Expand All @@ -71,7 +71,7 @@ def _load_the_model(self):

def _run_model(self):
if self.ignore_runtime_warnings:
with warnings.catch_warnings(record=True) as w:
with warnings.catch_warnings(record=True):
self.prob.run_model()
else:
self.prob.run_model()
Expand All @@ -82,7 +82,7 @@ def _run_model(self):
def _compute_totals(self):
of, wrt = self._get_derivative_inputs_outputs()
if self.ignore_runtime_warnings:
with warnings.catch_warnings(record=True) as w:
with warnings.catch_warnings(record=True):
self.derivatives = self.prob.compute_totals(of=of, wrt=wrt)
else:
self.derivatives = self.prob.compute_totals(of=of, wrt=wrt)
Expand Down
9 changes: 4 additions & 5 deletions mphys/utils/docs/_utils/docutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ def dedent(src):
lstrip = line.lstrip()
if lstrip: # keep going if first line(s) are blank.
tab = len(line) - len(lstrip)
return "\n".join(l[tab:] for l in lines[i:])
return "\n".join(s[tab:] for s in lines[i:])
return ""


Expand Down Expand Up @@ -764,9 +764,8 @@ def run_code(
if cls is None:
use_mpi = False
else:
try:
import mpi4py
except ImportError:
mpi4py_found = importlib.util.find_spec("mpi4py") is not None
if not mpi4py_found:
use_mpi = False
else:
N_PROCS = getattr(cls, "N_PROCS", 1)
Expand Down Expand Up @@ -899,7 +898,7 @@ def run_code(
except unittest.SkipTest as skip:
output = str(skip)
skipped = True
except Exception as exc:
except Exception:
output = "Running of embedded code {} in docs failed due to: \n\n{}".format(
path, traceback.format_exc()
)
Expand Down
3 changes: 1 addition & 2 deletions mphys/utils/docs/_utils/run_sub.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
import sys
import traceback

import numpy as np
from openmdao.utils.general_utils import printoptions

if __name__ == "__main__":
import openmdao.utils.mpi # this will activate use_proc_files
import openmdao.utils.mpi # noqa: F401, this will activate use_proc_files

try:
module_path = os.environ.get("OPENMDAO_CURRENT_MODULE", "").strip()
Expand Down
2 changes: 0 additions & 2 deletions mphys/utils/docs/_utils/upload_doc_version.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import os
import pipes
import subprocess
import sys

Expand Down

0 comments on commit 537bc99

Please sign in to comment.