Skip to content

Commit

Permalink
Fix TOML parser (All-Hands-AI#363)
Browse files Browse the repository at this point in the history
* fix toml

* Update opendevin/config.py

* install types

* install types

* Revert "install types"

This reverts commit 820b38b.

* fix install types

* non-interactive
  • Loading branch information
rbren authored Mar 29, 2024
1 parent 248c396 commit 3d7a86f
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 127 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ jobs:
with:
python-version: 3.11
- name: Install dependencies
run: pip install ruff mypy types-requests
run: pip install ruff mypy
- name: Run ruff
run: ruff check --config dev_config/python/ruff.toml opendevin/ agenthub/
- name: Run mypy
run: mypy --config-file dev_config/python/mypy.ini opendevin/ agenthub/
run: mypy --install-types --non-interactive --config-file dev_config/python/mypy.ini opendevin/ agenthub/
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ llama-index-embeddings-huggingface = "*"
llama-index-embeddings-azure-openai = "*"
llama-index-embeddings-ollama = "*"
google-generativeai = "*"
toml = "*"

[dev-packages]

Expand Down
147 changes: 25 additions & 122 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions opendevin/config.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import os
import tomllib
import toml

from dotenv import load_dotenv

load_dotenv()

with open("config.toml", "rb") as f:
config = tomllib.load(f)
config_str = ""
if os.path.exists("config.toml"):
with open("config.toml", "rb") as f:
config_str = f.read().decode("utf-8")

config = toml.loads(config_str)

def _get(key: str, default):
value = config.get(key, default)
Expand Down

0 comments on commit 3d7a86f

Please sign in to comment.