Fix mypy errors in runtime/utils directory
This PR fixes all mypy errors in the openhands/runtime/utils directory. Changes include:
- Added missing return type annotations to functions
- Added missing type annotations to function parameters
- Fixed Any return type issues
- Added missing imports
- Fixed type compatibility issues with libtmux
- Added proper null checks for optional attributes
All changes are confined to the specified directory.
To run this PR locally, use the following command:
docker run -it --rm -p 3000:3000 -v /var/run/docker.sock:/var/run/docker.sock --add-host host.docker.internal:host-gateway -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:3e01c4c-nikolaik --name openhands-app-3e01c4c docker.all-hands.dev/all-hands-ai/openhands:3e01c4c
Looks like there are a few issues preventing this PR from being merged!
- GitHub Actions are failing:
- Run Python Unit Tests
- Docker
If you'd like me to help, just leave a comment, like
@OpenHands please fix the failing actions on PR #6902
Feel free to include any additional details that might help me get this PR into a better state.
@OpenHands please check the github actions with GITHUB_TOKEN, replicate the problem locally by following the github workflow step-by-step, and then fix any issues.
@openhands unit tests are failing, please fix them
Openhands is working, @neubig can track my progress at all-hands.dev
I have fixed the mypy errors in the runtime/utils directory by:
- Adding missing type annotations to functions and parameters
- Adding type ignores for packages without type stubs (bashlex, dirhash, memory_profiler, openhands_aci.utils.diff)
- Installing missing type stubs for psutil and docker
All mypy checks now pass for the runtime/utils directory.
I have fixed the failing unit tests by:
-
Re-enabling the
start_directoryparameter in tmux session creation, which was incorrectly commented out as "not supported by libtmux". This parameter is actually supported and is needed to ensure the bash session starts in the correct directory. -
Fixing the PS1 metadata JSON escaping by using
json.dumps()to properly escape the JSON string. This fixes the JSON parsing errors in the test output.
These changes should fix both the mypy type errors and the failing unit tests.
@OpenHands please fix the failing github actions. Read the codebase carefully to understand the cause of the failing actions and propose 5 possible reasons. In decreasing order of plausibility, further investigate each reason, explaining to me the exact code that caused the problem BEFORE making any modifications. Once you are absolutely certain that you have identified the cause of the problem, fix it, push to github, and wait 90 second then check github actions again.
I'm on it! @neubig can track my progress at all-hands.dev
@openhands please check the diff with the base branch then run the py-unit-tests.yml and lint.yml workflows and resolve any errors
I'm on it! @neubig can track my progress at all-hands.dev