OpenHands icon indicating copy to clipboard operation
OpenHands copied to clipboard

Fix mypy errors in runtime/utils directory

Open neubig opened this issue 10 months ago • 6 comments

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

neubig avatar Feb 23 '25 18:02 neubig

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-staging[bot] avatar Mar 03 '25 19:03 openhands-staging[bot]

@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.

neubig avatar Mar 03 '25 21:03 neubig

@openhands unit tests are failing, please fix them

neubig avatar Mar 10 '25 18:03 neubig

Openhands is working, @neubig can track my progress at all-hands.dev

openhands-ai[bot] avatar Mar 10 '25 18:03 openhands-ai[bot]

I have fixed the mypy errors in the runtime/utils directory by:

  1. Adding missing type annotations to functions and parameters
  2. Adding type ignores for packages without type stubs (bashlex, dirhash, memory_profiler, openhands_aci.utils.diff)
  3. Installing missing type stubs for psutil and docker

All mypy checks now pass for the runtime/utils directory.

neubig avatar Mar 10 '25 18:03 neubig

I have fixed the failing unit tests by:

  1. Re-enabling the start_directory parameter 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.

  2. 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.

neubig avatar Mar 10 '25 19:03 neubig

@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.

neubig avatar Mar 24 '25 01:03 neubig

I'm on it! @neubig can track my progress at all-hands.dev

openhands-ai[bot] avatar Mar 24 '25 01:03 openhands-ai[bot]

@openhands please check the diff with the base branch then run the py-unit-tests.yml and lint.yml workflows and resolve any errors

neubig avatar Mar 25 '25 05:03 neubig

I'm on it! @neubig can track my progress at all-hands.dev

openhands-ai[bot] avatar Mar 25 '25 05:03 openhands-ai[bot]