Skip to content

Commit

Permalink
Fix linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jmthomas committed Jan 21, 2025
1 parent e92a0dc commit 56fdc7b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/api_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,12 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-dev.txt
working-directory: openc3-cosmos-script-runner-api
working-directory: openc3/python
- name: Lint with ruff
run: |
ruff --format=github scripts/*.py
ruff --config=../openc3/python/pyproject.toml --format=github scripts/*.py
working-directory: openc3-cosmos-script-runner-api
- name: Run unit tests
run: |
Expand Down
4 changes: 2 additions & 2 deletions openc3-cosmos-script-runner-api/scripts/run_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def run_script_log(id, message, color="BLACK", message_log=True):
| "open_file_dialog"
| "open_files_dialog"
):
if running_script.prompt_id != None:
if running_script.prompt_id is not None:
if (
"prompt_id" in parsed_cmd
and running_script.prompt_id
Expand Down Expand Up @@ -246,7 +246,7 @@ def run_script_log(id, message, color="BLACK", message_log=True):
run_script_log(
id, f"ERROR: Script command not handled: {msg['data']}", "RED"
)
except Exception as err:
except Exception:
tb = traceback.format_exc()
run_script_log(id, tb, "RED")
finally:
Expand Down
25 changes: 12 additions & 13 deletions openc3-cosmos-script-runner-api/scripts/running_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from openc3.utilities.string import build_timestamped_filename
from openc3.utilities.bucket_utilities import BucketUtilities
from openc3.script.storage import _get_storage_file
import re
import linecache


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

def stop_message_log(self):
metadata = {"id": self.id, "user": self.details["user"], "scriptname": self.unique_filename()}
metadata = {
"id": self.id,
"user": self.details["user"],
"scriptname": self.unique_filename(),
}
if RunningScript.my_message_log:
RunningScript.my_message_log.stop(True, metadata=metadata)
RunningScript.my_message_log = None
Expand All @@ -448,7 +451,7 @@ def set_filename(self, filename):

# Deal with breakpoints created under the previous filename.
bkpt_filename = self.unique_filename()
if not bkpt_filename in RunningScript.breakpoints:
if bkpt_filename not in RunningScript.breakpoints:
RunningScript.breakpoints[bkpt_filename] = RunningScript.breakpoints[
self.filename
]
Expand Down Expand Up @@ -539,7 +542,7 @@ def exception_instrumentation(self, filename, line_number):
if (
exc_type == StopScript
or exc_type == SkipScript
or exc_type == SkipTestCase # DEPRECATED but still valid
or exc_type == SkipTestCase # DEPRECATED but still valid
or not self.use_instrumentation
):
raise exc_value
Expand Down Expand Up @@ -597,20 +600,20 @@ def debug(self, debug_text):

@classmethod
def set_breakpoint(cls, filename, line_number):
if not filename in cls.breakpoints:
if filename not in cls.breakpoints:
cls.breakpoints[filename] = {}
cls.breakpoints[filename][line_number] = True

@classmethod
def clear_breakpoint(cls, filename, line_number):
if not filename in cls.breakpoints:
if filename not in cls.breakpoints:
cls.breakpoints[filename] = {}
if line_number in cls.breakpoints[filename]:
del cls.breakpoints[filename][line_number]

@classmethod
def clear_breakpoints(cls, filename=None):
if filename == None or filename == "":
if filename is None or filename == "":
cls.breakpoints = {}
else:
if filename in cls.breakpoints:
Expand Down Expand Up @@ -679,7 +682,7 @@ def handle_output_io(self, filename=None, line_number=None):
out_line = json_hash["log"]
if "message" in json_hash:
out_line = json_hash["message"]
except:
except Exception:
# Regular output
pass

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

def graceful_kill(self):
# Just to avoid warning
pass

def wait_for_go_or_stop(self, error=None, prompt=None):
count = -1
self.go = False
Expand Down Expand Up @@ -1098,7 +1097,7 @@ def run_text(
def handle_potential_tab_change(self, filename):
# Make sure the correct file is shown in script runner
if self.current_file != filename:
if not filename in self.call_stack:
if filename not in self.call_stack:
self.call_stack.append(filename)
self.load_file_into_script(filename)
self.current_file = filename
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# For details on the AST, see https://docs.python.org/3/library/ast.html
# and https://greentreesnakes.readthedocs.io/en/latest/nodes.html


# This class is used to instrument a Python script with calls to a
# RunningScript instance. The RunningScript instance is used to
# track the execution of the script, and can be used to pause and
Expand Down

0 comments on commit 56fdc7b

Please sign in to comment.