Skip to content
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

Enable strict type checking with mypy #6397

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
2 changes: 2 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ 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
neubig marked this conversation as resolved.
Show resolved Hide resolved

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