Skip to content

Commit 56fdc7b

Browse files
committed
Fix linter errors
1 parent e92a0dc commit 56fdc7b

File tree

4 files changed

+18
-17
lines changed

4 files changed

+18
-17
lines changed

.github/workflows/api_tests.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,12 @@ jobs:
107107
- name: Install dependencies
108108
run: |
109109
python -m pip install --upgrade pip
110+
pip install -r requirements.txt
110111
pip install -r requirements-dev.txt
111-
working-directory: openc3-cosmos-script-runner-api
112+
working-directory: openc3/python
112113
- name: Lint with ruff
113114
run: |
114-
ruff --format=github scripts/*.py
115+
ruff --config=../openc3/python/pyproject.toml --format=github scripts/*.py
115116
working-directory: openc3-cosmos-script-runner-api
116117
- name: Run unit tests
117118
run: |

openc3-cosmos-script-runner-api/scripts/run_script.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def run_script_log(id, message, color="BLACK", message_log=True):
164164
| "open_file_dialog"
165165
| "open_files_dialog"
166166
):
167-
if running_script.prompt_id != None:
167+
if running_script.prompt_id is not None:
168168
if (
169169
"prompt_id" in parsed_cmd
170170
and running_script.prompt_id
@@ -246,7 +246,7 @@ def run_script_log(id, message, color="BLACK", message_log=True):
246246
run_script_log(
247247
id, f"ERROR: Script command not handled: {msg['data']}", "RED"
248248
)
249-
except Exception as err:
249+
except Exception:
250250
tb = traceback.format_exc()
251251
run_script_log(id, tb, "RED")
252252
finally:

openc3-cosmos-script-runner-api/scripts/running_script.py

+12-13
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
from openc3.utilities.string import build_timestamped_filename
1919
from openc3.utilities.bucket_utilities import BucketUtilities
2020
from openc3.script.storage import _get_storage_file
21-
import re
2221
import linecache
2322

2423

@@ -435,7 +434,11 @@ def unique_filename(self):
435434
return "Untitled" + str(RunningScript.id)
436435

437436
def stop_message_log(self):
438-
metadata = {"id": self.id, "user": self.details["user"], "scriptname": self.unique_filename()}
437+
metadata = {
438+
"id": self.id,
439+
"user": self.details["user"],
440+
"scriptname": self.unique_filename(),
441+
}
439442
if RunningScript.my_message_log:
440443
RunningScript.my_message_log.stop(True, metadata=metadata)
441444
RunningScript.my_message_log = None
@@ -448,7 +451,7 @@ def set_filename(self, filename):
448451

449452
# Deal with breakpoints created under the previous filename.
450453
bkpt_filename = self.unique_filename()
451-
if not bkpt_filename in RunningScript.breakpoints:
454+
if bkpt_filename not in RunningScript.breakpoints:
452455
RunningScript.breakpoints[bkpt_filename] = RunningScript.breakpoints[
453456
self.filename
454457
]
@@ -539,7 +542,7 @@ def exception_instrumentation(self, filename, line_number):
539542
if (
540543
exc_type == StopScript
541544
or exc_type == SkipScript
542-
or exc_type == SkipTestCase # DEPRECATED but still valid
545+
or exc_type == SkipTestCase # DEPRECATED but still valid
543546
or not self.use_instrumentation
544547
):
545548
raise exc_value
@@ -597,20 +600,20 @@ def debug(self, debug_text):
597600

598601
@classmethod
599602
def set_breakpoint(cls, filename, line_number):
600-
if not filename in cls.breakpoints:
603+
if filename not in cls.breakpoints:
601604
cls.breakpoints[filename] = {}
602605
cls.breakpoints[filename][line_number] = True
603606

604607
@classmethod
605608
def clear_breakpoint(cls, filename, line_number):
606-
if not filename in cls.breakpoints:
609+
if filename not in cls.breakpoints:
607610
cls.breakpoints[filename] = {}
608611
if line_number in cls.breakpoints[filename]:
609612
del cls.breakpoints[filename][line_number]
610613

611614
@classmethod
612615
def clear_breakpoints(cls, filename=None):
613-
if filename == None or filename == "":
616+
if filename is None or filename == "":
614617
cls.breakpoints = {}
615618
else:
616619
if filename in cls.breakpoints:
@@ -679,7 +682,7 @@ def handle_output_io(self, filename=None, line_number=None):
679682
out_line = json_hash["log"]
680683
if "message" in json_hash:
681684
out_line = json_hash["message"]
682-
except:
685+
except Exception:
683686
# Regular output
684687
pass
685688

@@ -722,10 +725,6 @@ def handle_output_io(self, filename=None, line_number=None):
722725
# Add to the message log
723726
self.message_log().write(lines_to_write)
724727

725-
def graceful_kill(self):
726-
# Just to avoid warning
727-
pass
728-
729728
def wait_for_go_or_stop(self, error=None, prompt=None):
730729
count = -1
731730
self.go = False
@@ -1098,7 +1097,7 @@ def run_text(
10981097
def handle_potential_tab_change(self, filename):
10991098
# Make sure the correct file is shown in script runner
11001099
if self.current_file != filename:
1101-
if not filename in self.call_stack:
1100+
if filename not in self.call_stack:
11021101
self.call_stack.append(filename)
11031102
self.load_file_into_script(filename)
11041103
self.current_file = filename

openc3-cosmos-script-runner-api/scripts/script_instrumentor.py

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
# For details on the AST, see https://docs.python.org/3/library/ast.html
2121
# and https://greentreesnakes.readthedocs.io/en/latest/nodes.html
2222

23+
2324
# This class is used to instrument a Python script with calls to a
2425
# RunningScript instance. The RunningScript instance is used to
2526
# track the execution of the script, and can be used to pause and

0 commit comments

Comments
 (0)