static typechecking (mypy) failures with chalice 1.22.2
- Dominant language
- Python
- Stars
- 11.1k
- Forks
- 1k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 2
Description
My app has been passing `mypy` static type checks just great until I upgraded from `1.22.1` to `1.22.2`.
I've removed some of the errors below for brevity.
```bash
$ pip freeze | grep chalice
chalice==1.22.1
$ mypy --config-file mypy.ini chalicelib
✅ Success: no issues found in 82 source files
$ pip install chalice==1.22.2 --upgrade
$ mypy --config-file mypy.ini chalicelib
chalicelib/init_app.py:9: error: "APIGateway" has no attribute "cors"
chalicelib/routes/main.py:11: error: Module 'chalice.app' has no attribute 'MultiDict'
chalicelib/routes/main.py:13: error: Too many arguments for "Blueprint"
chalicelib/routes/main.py:41: error: Incompatible types in assignment (expression has type "Union[str, Dict[str, Any]]", variable has type "Dict[str, Any]")
chalicelib/routes/docs_route.py:28: error: Too many arguments for "Blueprint"
chalicelib/util/authorizer.py:80: error: Too many arguments for "AuthResponse"
chalicelib/routes/type_route.py:8: error: Module 'chalice.app' has no attribute 'MultiDict'
chalicelib/routes/type_route.py:14: error: Too many arguments for "Blueprint"
chalicelib/routes/transaction_route.py:63: error: Argument 2 to "Response" has incompatible type "None"; expected "Dict[str, str]"
chalicelib/routes/transaction_route.py:66: error: Too many arguments for "Blueprint"
chalicelib/routes/search_route.py:4: error: Module 'chalice.app' has no attribute 'MultiDict'
chalicelib/routes/search_route.py:10: error: Too many arguments for "Blueprint"
🚫 Found 38 errors in 24 files (checked 82 source files)
```
I can't see why. What has changed in `chalice`, and why is my code failing `mypy` now?
Example of failed static typechecking from `init_app.py`:
`chalicelib/init_app.py:9: error: "APIGateway" has no attribute "cors"`
```python
from chalice import Chalice, CORSConfig
APP = Chalice(app_name='myapp')
APP.api.cors = CORSConfig(
allow_origin = '*',
allow_credentials=True
)
```
Contributor guide
Research direction
Reproduce the report with mypy --config-file mypy.ini chalicelib, then compare Chalice 1.22.1 and 1.22.2 declarations for APIGateway, MultiDict, Blueprint, AuthResponse, and Response. Check the examples in chalicelib/init_app.py and the listed route files; done means the application passes mypy again with Chalice 1.22.2.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100