π OpenHands: AI-Driven Development
Fix python linter inconsistent behaviour with quotes (#1112)
Boxuan Liaed82704a947
diff --git a/Makefile b/Makefileindex abc172fb2f..669f1b885b 100644--- a/Makefile+++ b/Makefile@@ -106,6 +106,10 @@ install-precommit-hooks:@poetry run pre-commit install --config $(PRECOMMIT_CONFIG_PATH)@echo "$(GREEN)Pre-commit hooks installed successfully.$(RESET)"+lint:+ @echo "$(YELLOW)Running linters...$(RESET)"+ @poetry run pre-commit run --files opendevin/**/* agenthub/**/* --show-diff-on-failure --config $(PRECOMMIT_CONFIG_PATH)+build-frontend:@echo "$(YELLOW)Building frontend...$(RESET)"@cd frontend && npm run build@@ -178,6 +182,7 @@ help:@echo "$(BLUE)Usage: make [target]$(RESET)"@echo "Targets:"@echo " $(GREEN)build$(RESET) - Build project, including environment setup and dependencies."+ @echo " $(GREEN)lint$(RESET) - Run linters on the project."@echo " $(GREEN)setup-config$(RESET) - Setup the configuration for OpenDevin by providing LLM API key,"@echo " LLM Model name, and workspace directory."@echo " $(GREEN)start-backend$(RESET) - Start the backend server for the OpenDevin project."@@ -187,4 +192,4 @@ help:@echo " $(GREEN)help$(RESET) - Display this help message, providing information on available targets."# Phony targets-.PHONY: build check-dependencies check-python check-npm check-docker check-poetry pull-docker-image install-python-dependencies install-frontend-dependencies install-precommit-hooks start-backend start-frontend run setup-config setup-config-prompts help+.PHONY: build check-dependencies check-python check-npm check-docker check-poetry pull-docker-image install-python-dependencies install-frontend-dependencies install-precommit-hooks lint start-backend start-frontend run setup-config setup-config-prompts helpdiff --git a/dev_config/python/.pre-commit-config.yaml b/dev_config/python/.pre-commit-config.yamlindex 931b57297a..591b3b8714 100644--- a/dev_config/python/.pre-commit-config.yaml+++ b/dev_config/python/.pre-commit-config.yaml@@ -1,12 +1,19 @@repos:- repo: https://github.com/pre-commit/pre-commit-hooks- rev: v3.2.0+ rev: v4.5.0hooks:- id: trailing-whitespace- id: end-of-file-fixer- id: check-yaml- id: debug-statements- - id: double-quote-string-fixer++ - repo: https://github.com/PyCQA/flake8+ rev: 7.0.0+ hooks:+ - id: flake8+ args: ['--select=Q000'] # Q000 is the error code for single quote enforcement+ additional_dependencies:+ - flake8-quotes- repo: https://github.com/hhatto/autopep8rev: v2.1.0diff --git a/opendevin/config.py b/opendevin/config.pyindex 26a6a7c775..f9dd8656e8 100644--- a/opendevin/config.py+++ b/opendevin/config.py@@ -61,7 +61,7 @@ def parse_arguments():args, _ = parser.parse_known_args()if args.directory:config[ConfigType.WORKSPACE_BASE] = os.path.abspath(args.directory)- print(f"Setting workspace base to {config[ConfigType.WORKSPACE_BASE]}")+ print(f'Setting workspace base to {config[ConfigType.WORKSPACE_BASE]}')parse_arguments()diff --git a/poetry.lock b/poetry.lockindex f1f44e0cc6..1f656fe5e3 100644--- a/poetry.lock+++ b/poetry.lock@@ -173,6 +173,20 @@ tests = ["attrs[tests-no-zope]", "zope-interface"]tests-mypy = ["mypy (>=1.6)", "pytest-mypy-plugins"]tests-no-zope = ["attrs[tests-mypy]", "cloudpickle", "hypothesis", "pympler", "pytest (>=4.3.0)", "pytest-xdist[psutil]"]+[[package]]+name = "autopep8"+version = "2.1.0"+description = "A tool that automatically formats Python code to conform to the PEP 8 style guide"+optional = false+python-versions = ">=3.8"+files = [+ {file = "autopep8-2.1.0-py2.py3-none-any.whl", hash = "sha256:2bb76888c5edbcafe6aabab3c47ba534f5a2c2d245c2eddced4a30c4b4946357"},+ {file = "autopep8-2.1.0.tar.gz", hash = "sha256:1fa8964e4618929488f4ec36795c7ff12924a68b8bf01366c094fc52f770b6e7"},+]++[package.dependencies]+pycodestyle = ">=2.11.0"+[[package]]name = "azure-core"version = "1.30.1"@@ -932,6 +946,22 @@ docs = ["furo (>=2023.9.10)", "sphinx (>=7.2.6)", "sphinx-autodoc-typehints (>=1testing = ["covdefaults (>=2.3)", "coverage (>=7.3.2)", "diff-cover (>=8.0.1)", "pytest (>=7.4.3)", "pytest-cov (>=4.1)", "pytest-mock (>=3.12)", "pytest-timeout (>=2.2)"]typing = ["typing-extensions (>=4.8)"]+[[package]]+name = "flake8"+version = "7.0.0"+description = "the modular source code checker: pep8 pyflakes and co"+optional = false+python-versions = ">=3.8.1"+files = [+ {file = "flake8-7.0.0-py2.py3-none-any.whl", hash = "sha256:a6dfbb75e03252917f2473ea9653f7cd799c3064e54d4c8140044c5c065f53c3"},+ {file = "flake8-7.0.0.tar.gz", hash = "sha256:33f96621059e65eec474169085dc92bf26e7b2d47366b70be2f67ab80dc25132"},+]++[package.dependencies]+mccabe = ">=0.7.0,<0.8.0"+pycodestyle = ">=2.11.0,<2.12.0"+pyflakes = ">=3.2.0,<3.3.0"+[[package]]name = "flatbuffers"version = "24.3.25"@@ -2397,6 +2427,17 @@ pillow = ">=8"pyparsing = ">=2.3.1"python-dateutil = ">=2.7"+[[package]]+name = "mccabe"+version = "0.7.0"+description = "McCabe checker, plugin for flake8"+optional = false+python-versions = ">=3.6"+files = [+ {file = "mccabe-0.7.0-py2.py3-none-any.whl", hash = "sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e"},+ {file = "mccabe-0.7.0.tar.gz", hash = "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325"},+]+[[package]]name = "mdurl"version = "0.1.2"@@ -3801,6 +3842,17 @@ files = [[package.dependencies]pyasn1 = ">=0.4.6,<0.7.0"+[[package]]+name = "pycodestyle"+version = "2.11.1"+description = "Python style guide checker"+optional = false+python-versions = ">=3.8"+files = [+ {file = "pycodestyle-2.11.1-py2.py3-none-any.whl", hash = "sha256:44fe31000b2d866f2e41841b18528a505fbd7fef9017b04eff4e2648a0fadc67"},+ {file = "pycodestyle-2.11.1.tar.gz", hash = "sha256:41ba0e7afc9752dfb53ced5489e89f8186be00e599e712660695b7a75ff2663f"},+]+[[package]]name = "pycparser"version = "2.22"@@ -3939,6 +3991,17 @@ typing-extensions = "*"[package.extras]dev = ["black", "build", "flake8", "flake8-black", "isort", "jupyter-console", "mkdocs", "mkdocs-include-markdown-plugin", "mkdocstrings[python]", "pytest", "pytest-asyncio", "pytest-trio", "sphinx", "toml", "tox", "trio", "trio", "trio-typing", "twine", "twisted", "validate-pyproject[all]"]+[[package]]+name = "pyflakes"+version = "3.2.0"+description = "passive checker of Python programs"+optional = false+python-versions = ">=3.8"+files = [+ {file = "pyflakes-3.2.0-py2.py3-none-any.whl", hash = "sha256:84b5be138a2dfbb40689ca07e2152deb896a65c3a3e24c251c5c62489568074a"},+ {file = "pyflakes-3.2.0.tar.gz", hash = "sha256:1c61603ff154621fb2a9172037d84dca3500def8c8b630657d1701f026f8af3f"},+]+[[package]]name = "pygments"version = "2.17.2"@@ -5907,4 +5970,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p[metadata]lock-version = "2.0"python-versions = "^3.11"-content-hash = "2157e2433781d90b46d2e153a34282b17666e9d6bdcb1777788f204349ca0159"+content-hash = "3a5ca3c8b47e0e43994032d1620d85a8d602c52a93790d192b9fdb3a8ac36d97"diff --git a/pyproject.toml b/pyproject.tomlindex 02967edf3e..2ffe09ecfc 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -34,6 +34,8 @@ llama-index-embeddings-azure-openai = "*"llama-index-embeddings-ollama = "*"[tool.poetry.group.dev.dependencies]+autopep8 = "v2.1.0"+flake8 = "7.0.0"ruff = "0.3.7"mypy = "1.9.0"pre-commit = "3.7.0"@@ -44,9 +46,14 @@ pytest = "*"[tool.poetry.group.evaluation.dependencies]torch = "*"-[tool.autopep8]-ignore = [ "E501" ]-[build-system]requires = ["poetry-core"]build-backend = "poetry.core.masonry.api"++[tool.autopep8]+# autopep8 fights with mypy on line length issue+ignore = [ "E501" ]++[tool.black]+# prevent black (if installed) from changing single quotes to double quotes+skip-string-normalization = true