Skip to content

πŸ™Œ OpenHands: AI-Driven Development

fix: restore python linting. (#2228)

Leo9ada36e30b83
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index 0ff1f383e0..4fff2a1754 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -47,11 +47,4 @@ jobs:
- name: Install pre-commit
run: pip install pre-commit==3.7.0
- name: Run pre-commit hooks
- if: github.ref != 'refs/heads/main'
- run: |
- git fetch https://github.com/OpenDevin/OpenDevin.git main:main && \
- pre-commit run \
- --files \
- $(git diff --name-only $(git merge-base main $(git branch --show-current)) $(git branch --show-current) | tr '\n' ' ') \
- --show-diff-on-failure \
- --config ./dev_config/python/.pre-commit-config.yaml
+ run: pre-commit run --files opendevin/**/* agenthub/**/* evaluation/**/* --show-diff-on-failure --config ./dev_config/python/.pre-commit-config.yaml
diff --git a/Makefile b/Makefile
index 098888d80d..29db6389de 100644
--- a/Makefile
+++ b/Makefile
@@ -172,7 +172,7 @@ install-precommit-hooks:
lint-backend:
@echo "$(YELLOW)Running linters...$(RESET)"
- @poetry run pre-commit run --files $$(git diff --name-only $$(git merge-base main $$(git branch --show-current)) $$(git branch --show-current) | tr '\n' ' ') --show-diff-on-failure --config $(PRECOMMIT_CONFIG_PATH)
+ @poetry run pre-commit run --files opendevin/**/* agenthub/**/* evaluation/**/* --show-diff-on-failure --config $(PRECOMMIT_CONFIG_PATH)
lint-frontend:
@echo "$(YELLOW)Running linters for frontend...$(RESET)"
diff --git a/agenthub/browsing_agent/prompt.py b/agenthub/browsing_agent/prompt.py
index 8f6702adfa..5c62b67204 100644
--- a/agenthub/browsing_agent/prompt.py
+++ b/agenthub/browsing_agent/prompt.py
@@ -494,11 +494,13 @@ def _get_action_space(flags: Flags) -> AbstractActionSet:
action_space = PythonActionSet(strict=flags.is_strict)
if flags.multi_actions:
warn(
- f'Flag action_space={repr(flags.action_space)} incompatible with multi_actions={repr(flags.multi_actions)}.'
+ f'Flag action_space={repr(flags.action_space)} incompatible with multi_actions={repr(flags.multi_actions)}.',
+ stacklevel=2,
)
if flags.demo_mode != 'off':
warn(
- f'Flag action_space={repr(flags.action_space)} incompatible with demo_mode={repr(flags.demo_mode)}.'
+ f'Flag action_space={repr(flags.action_space)} incompatible with demo_mode={repr(flags.demo_mode)}.',
+ stacklevel=2,
)
return action_space
case 'bid':
diff --git a/agenthub/browsing_agent/utils.py b/agenthub/browsing_agent/utils.py
index 6466187397..e98ae3c5ce 100644
--- a/agenthub/browsing_agent/utils.py
+++ b/agenthub/browsing_agent/utils.py
@@ -16,7 +16,7 @@ def yaml_parser(message):
valid = True
retry_message = ''
except yaml.YAMLError as e:
- warn(str(e))
+ warn(str(e), stacklevel=2)
value = {}
valid = False
retry_message = "Your response is not a valid yaml. Please try again and be careful to the format. Don't add any apology or comment, just the answer."
diff --git a/evaluation/EDA/game.py b/evaluation/EDA/game.py
index 09ec16ca82..1c057ca8f8 100644
--- a/evaluation/EDA/game.py
+++ b/evaluation/EDA/game.py
@@ -9,6 +9,7 @@ from retry import retry
LOGGER = logging.getLogger(__name__)
+
class Q20Game:
def __init__(
self,
@@ -19,8 +20,10 @@ class Q20Game:
temperature: float = 0.8,
openai_api: bool = True,
openai_api_key: Optional[str] = None,
- guesser_kargs={},
+ guesser_kargs=None,
) -> None:
+ if guesser_kargs is None:
+ guesser_kargs = {}
self.item = item
self.answerer_model = answerer_model
self.guesser_model = guesser_model
diff --git a/evaluation/gaia/scorer.py b/evaluation/gaia/scorer.py
index da4177d61b..f361485cc9 100644
--- a/evaluation/gaia/scorer.py
+++ b/evaluation/gaia/scorer.py
@@ -17,8 +17,10 @@ def normalize_number_str(number_str: str) -> float:
def split_string(
s: str,
- char_list: list[str] = [',', ';'],
+ char_list: list[str] = None,
) -> list[str]:
+ if char_list is None:
+ char_list = [',', ';']
pattern = f"[{''.join(char_list)}]"
return re.split(pattern, s)
@@ -51,7 +53,9 @@ def question_scorer(
# check length is the same
if len(gt_elems) != len(ma_elems):
warnings.warn(
- 'Answer lists have different lengths, returning False.', UserWarning
+ 'Answer lists have different lengths, returning False.',
+ UserWarning,
+ stacklevel=2,
)
return False
diff --git a/evaluation/logic_reasoning/instruction.txt b/evaluation/logic_reasoning/instruction.txt
index 447634793e..bb49e883c7 100644
--- a/evaluation/logic_reasoning/instruction.txt
+++ b/evaluation/logic_reasoning/instruction.txt
@@ -1,6 +1,6 @@
-You are a helpful assistant assigned with logic reasoning task. You need to determine the correctness of a query given some facts and fules.
+You are a helpful assistant assigned with logic reasoning task. You need to determine the correctness of a query given some facts and rules.
you can interact with an interactive Python (Jupyter Notebook) environment and receive the corresponding output when needed. The code should be enclosed using "<execute_ipython>" tag.
-In this task, you need to use the code in [[logic_inference_path.py]] to help you. Specifically, you first need to instantiate a **LogicInferenceEngine** class and use the **safe_execute_program** method to prove the **logic programs**. You should receive *answer*, *flag*, *error_message* from the output.
+In this task, you need to use the code in [[logic_inference_path.py]] to help you. Specifically, you first need to instantiate a **LogicInferenceEngine** class and use the **safe_execute_program** method to prove the **logic programs**. You should receive *answer*, *flag*, *error_message* from the output.
An example would be look like this:
<execute_ipython>
@@ -17,4 +17,3 @@ dataset_name:
logic_programs:
[[logic_programs]]
-