π OpenHands: AI-Driven Development
Ad/fix pre commit (#807)
Anas DORBANId38113ceadcc
diff --git a/Makefile b/Makefileindex 50225adfbd..d658a261c8 100644--- a/Makefile+++ b/Makefile@@ -60,9 +60,6 @@ build:@curl -sSL https://install.python-poetry.org | python3 -@poetry install --without evaluation@echo "$(GREEN)Activating Poetry shell...$(RESET)"- @echo "$(GREEN)Installing pre-commit hooks...$(RESET)"- @git config --unset-all core.hooksPath || true- @poetry run pre-commit install --config $(PRECOMMIT_CONFIG_PATH)@echo "$(GREEN)Setting up frontend environment...$(RESET)"@echo "$(YELLOW)Detect Node.js version...$(RESET)"@cd frontend && node ./scripts/detect-node-version.js@@ -71,6 +68,9 @@ build:rm -rf node_modules; \fi@cd frontend && echo "$(BLUE)Enabling pnpm...$(RESET)" && corepack enable && echo "$(BLUE)Installing frontend dependencies with pnpm...$(RESET)" && pnpm install && echo "$(BLUE)Running make-i18n with pnpm...$(RESET)" && pnpm run make-i18n+ @echo "$(GREEN)Installing pre-commit hooks...$(RESET)"+ @git config --unset-all core.hooksPath || true+ @poetry run pre-commit install --config $(PRECOMMIT_CONFIG_PATH)@echo "$(GREEN)Build completed successfully.$(RESET)"# Start backend@@ -107,7 +107,7 @@ setup-config:@read -p "Enter your LLM API key: " llm_api_key; \echo "LLM_API_KEY=\"$$llm_api_key\"" >> $(CONFIG_FILE).tmp-+@read -p "Enter your LLM Base URL [mostly used for local LLMs, leave blank if not needed - example: http://localhost:5001/v1/]: " llm_base_url; \if [[ ! -z "$$llm_base_url" ]]; then echo "LLM_BASE_URL=\"$$llm_base_url\"" >> $(CONFIG_FILE).tmp; fi@@ -148,4 +148,4 @@ help:@echo " $(GREEN)help$(RESET) - Display this help message, providing information on available targets."# Phony targets-.PHONY: build build-eval start-backend start-frontend run setup-config help\ No newline at end of file+.PHONY: build build-eval start-backend start-frontend run setup-config helpdiff --git a/dev_config/python/.pre-commit-config.yaml b/dev_config/python/.pre-commit-config.yamlindex eccbe9a3ca..29f50941b6 100644--- a/dev_config/python/.pre-commit-config.yaml+++ b/dev_config/python/.pre-commit-config.yaml@@ -7,7 +7,6 @@ repos:- id: check-yaml- id: debug-statements- id: double-quote-string-fixer- - id: requirements-txt-fixer- repo: https://github.com/hhatto/autopep8rev: v2.1.0@@ -22,18 +21,24 @@ repos:pass_filenames: false- repo: https://github.com/astral-sh/ruff-pre-commit- rev: v0.3.3+ # Ruff version.+ rev: v0.3.5hooks:+ # Run the linter.- id: ruffentry: ruff check --config dev_config/python/ruff.toml opendevin/ agenthub/- always_run: true- pass_filenames: false+ types_or: [ python, pyi, jupyter ]+ args: [ --fix ]+ # Run the formatter.+ - id: ruff-format+ entry: ruff check --config dev_config/python/ruff.toml opendevin/ agenthub/+ types_or: [ python, pyi, jupyter ]- repo: https://github.com/pre-commit/mirrors-mypyrev: v1.9.0hooks:- id: mypy- additional_dependencies: [types-requests, types-setuptools]+ additional_dependencies: [types-requests, types-setuptools, types-pyyaml, types-toml]entry: mypy --config-file dev_config/python/mypy.ini opendevin/ agenthub/always_run: truepass_filenames: falsediff --git a/opendevin/config.py b/opendevin/config.pyindex 765dc1e146..3e61096bb6 100644--- a/opendevin/config.py+++ b/opendevin/config.py@@ -1,38 +1,37 @@import os-import toml # type: ignore+import tomlfrom dotenv import load_dotenvload_dotenv()DEFAULT_CONFIG = {- "LLM_API_KEY": None,- "LLM_BASE_URL": None,- "WORKSPACE_DIR": os.path.join(os.getcwd(), "workspace"),- "LLM_MODEL": "gpt-4-0125-preview",- "SANDBOX_CONTAINER_IMAGE": "ghcr.io/opendevin/sandbox",- "RUN_AS_DEVIN": "false",- "LLM_EMBEDDING_MODEL": "local",- "LLM_NUM_RETRIES": 6,- "LLM_COOLDOWN_TIME" : 1,- "DIRECTORY_REWRITE" : "",- "PROMPT_DEBUG_DIR": "",- "MAX_ITERATIONS": 100,+ 'LLM_API_KEY': None,+ 'LLM_BASE_URL': None,+ 'WORKSPACE_DIR': os.path.join(os.getcwd(), 'workspace'),+ 'LLM_MODEL': 'gpt-4-0125-preview',+ 'SANDBOX_CONTAINER_IMAGE': 'ghcr.io/opendevin/sandbox',+ 'RUN_AS_DEVIN': 'false',+ 'LLM_EMBEDDING_MODEL': 'local',+ 'LLM_NUM_RETRIES': 6,+ 'LLM_COOLDOWN_TIME': 1,+ 'DIRECTORY_REWRITE': '',+ 'PROMPT_DEBUG_DIR': '',+ 'MAX_ITERATIONS': 100,}-config_str = ""-if os.path.exists("config.toml"):- with open("config.toml", "rb") as f:- config_str = f.read().decode("utf-8")+config_str = ''+if os.path.exists('config.toml'):+ with open('config.toml', 'rb') as f:+ config_str = f.read().decode('utf-8')tomlConfig = toml.loads(config_str)config = DEFAULT_CONFIG.copy()for key, value in config.items():- if key in os.environ:- config[key] = os.environ[key]- elif key in tomlConfig:- config[key] = tomlConfig[key]-+ if key in os.environ:+ config[key] = os.environ[key]+ elif key in tomlConfig:+ config[key] = tomlConfig[key]def _get(key: str, default):@@ -65,6 +64,7 @@ def get_or_none(key: str):"""return _get(key, None)+def get(key: str):"""Get a key from the config, please make sure it exists.diff --git a/tests/test_action_serialization.py b/tests/test_action_serialization.pyindex d58ac78199..ba7e9202c2 100644--- a/tests/test_action_serialization.py+++ b/tests/test_action_serialization.py@@ -1,4 +1,3 @@-import pytestfrom opendevin.action import (action_from_dict,Action,