Skip to content

Add strict mypy checking #6397

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 25 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
66bd8fd
Enable strict type checking with mypy
openhands-agent Jan 21, 2025
7a25991
Update .github/workflows/lint.yml
neubig Jan 21, 2025
64ebef3
Update .github/workflows/lint.yml
neubig Jan 21, 2025
66a7920
Merge branch 'main' into feature/strict-mypy-checks
neubig Feb 10, 2025
d309455
Merge branch 'main' into feature/strict-mypy-checks
neubig Feb 11, 2025
592aca0
Merge branch 'main' into feature/strict-mypy-checks
neubig Feb 19, 2025
d35bbec
Merge branch 'main' into feature/strict-mypy-checks
neubig Feb 19, 2025
842d77a
Merge branch 'main' into feature/strict-mypy-checks
neubig Feb 21, 2025
18d8aa9
Merge branch 'main' into feature/strict-mypy-checks
neubig Feb 22, 2025
b147f6a
Merge branch 'main' into feature/strict-mypy-checks
neubig Feb 24, 2025
40668d4
Merge branch 'main' into feature/strict-mypy-checks
neubig Feb 24, 2025
12591f4
Merge branch 'main' into feature/strict-mypy-checks
neubig Mar 4, 2025
81ab5d3
Merge branch 'main' into feature/strict-mypy-checks
neubig Mar 4, 2025
0cced79
Merge main into feature/strict-mypy-checks
openhands-agent Mar 5, 2025
5be073e
Merge branch 'main' into feature/strict-mypy-checks
neubig Mar 24, 2025
a2e1675
Merge main into feature/strict-mypy-checks (keeping our poetry.lock)
openhands-agent Mar 24, 2025
b3a9382
Merge branch 'main' into feature/strict-mypy-checks
neubig Mar 25, 2025
c90b9aa
Merge branch 'main' into feature/strict-mypy-checks
neubig Mar 25, 2025
33d2907
Merge branch 'main' into feature/strict-mypy-checks
neubig Mar 25, 2025
923d642
Merge branch 'main' into feature/strict-mypy-checks
neubig Mar 25, 2025
7327c75
Merge branch 'main' into feature/strict-mypy-checks
neubig Apr 1, 2025
c13cbc9
Merge branch 'main' into feature/strict-mypy-checks
neubig Apr 3, 2025
52f9ac4
Merge branch 'main' into feature/strict-mypy-checks
neubig Apr 6, 2025
521c61c
Merge branch 'main' into feature/strict-mypy-checks
neubig Apr 8, 2025
a8aed3a
Merge branch 'main' into feature/strict-mypy-checks
neubig Apr 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,20 @@ jobs:
cache: 'pip'
- name: Install pre-commit
run: pip install pre-commit==3.7.0
- name: Install project in editable mode
run: pip install -e .
- name: Run pre-commit hooks
run: pre-commit run --files openhands/**/* evaluation/**/* tests/**/* --show-diff-on-failure --config ./dev_config/python/.pre-commit-config.yaml
- name: Run mypy directly (for better error reporting)
if: always() # Run even if pre-commit fails
run: |
pip install mypy==1.9.0 \
types-requests types-setuptools types-pyyaml types-toml \
types-redis types-protobuf types-python-dateutil types-pyjwt \
types-docutils types-Pillow types-boto3 types-cryptography \
types-Jinja2 types-MarkupSafe types-click types-filelock \
types-decorator types-docopt types-emoji types-enum34 types-paramiko
PYTHONPATH=$PWD mypy --config-file dev_config/python/mypy.ini --scripts-are-modules openhands/

# Check version consistency across documentation
check-version-consistency:
Expand Down
26 changes: 24 additions & 2 deletions dev_config/python/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,30 @@ repos:
rev: v1.9.0
hooks:
- id: mypy
name: mypy (with strict type checking)
additional_dependencies:
[types-requests, types-setuptools, types-pyyaml, types-toml]
entry: mypy --config-file dev_config/python/mypy.ini openhands/
- types-requests
- types-setuptools
- types-pyyaml
- types-toml
- types-redis
- types-protobuf
- types-python-dateutil
- types-pyjwt
- types-docutils
- types-Pillow
- types-boto3
- types-cryptography
- types-Jinja2
- types-MarkupSafe
- types-click
- types-filelock
- types-decorator
- types-docopt
- types-emoji
- types-enum34
- types-paramiko
entry: mypy --config-file dev_config/python/mypy.ini --scripts-are-modules openhands/
always_run: true
pass_filenames: false
verbose: true
28 changes: 24 additions & 4 deletions dev_config/python/mypy.ini
Original file line number Diff line number Diff line change
@@ -1,9 +1,29 @@
[mypy]
warn_unused_configs = True
# Error output
show_error_codes = True
pretty = True
show_column_numbers = True

# Import discovery
ignore_missing_imports = True
follow_imports = normal

# Untyped definitions and calls
disallow_untyped_defs = True
check_untyped_defs = True
explicit_package_bases = True
warn_unreachable = True
warn_redundant_casts = True
disallow_incomplete_defs = True
disallow_untyped_decorators = True

# None and Optional handling
no_implicit_optional = True
strict_optional = True

# Warnings
warn_unused_configs = True
warn_redundant_casts = True
warn_unused_ignores = True
warn_return_any = True
warn_unreachable = True

# Misc
explicit_package_bases = True
Loading