Skip to content

Commit f6c2afc

Browse files
committed
Improve typing in the module
Fixes pallets-eco#65 - make it pass mypy tests (i.e., improve type hinting) - add mypy test to CI - add py.typed to setup so that other packages recognize it's typed - enable async view function decoration (via ensure_sync() as noted on https://flask.palletsprojects.com/en/latest/async-await/#extensions) Signed-off-by: Marek Pikuła <[email protected]>
1 parent 064976a commit f6c2afc

File tree

7 files changed

+192
-116
lines changed

7 files changed

+192
-116
lines changed

Diff for: .github/workflows/tests.yml

+20
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,26 @@ name: Tests
33
on: [push, pull_request]
44

55
jobs:
6+
mypy:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
fail-fast: false
10+
11+
steps:
12+
- uses: actions/checkout@v1
13+
- name: Set up Python 3.7
14+
uses: actions/setup-python@v1
15+
with:
16+
python-version: "3.7"
17+
- name: Install dependencies
18+
if: steps.cache-pip.outputs.cache-hit != 'true'
19+
run: |
20+
python -m pip install --upgrade pip
21+
pip install -r requirements/test.pip
22+
- name: Run mypy satic check
23+
run: |
24+
python3 -m mypy flask_pydantic/
25+
626
build:
727
runs-on: ${{ matrix.os }}
828
strategy:

Diff for: flask_pydantic/converters.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
from typing import Type
1+
from typing import Dict, List, Type, Union
22

33
from pydantic import BaseModel
4-
from werkzeug.datastructures import ImmutableMultiDict
4+
from werkzeug.datastructures import MultiDict
55

66

77
def convert_query_params(
8-
query_params: ImmutableMultiDict, model: Type[BaseModel]
9-
) -> dict:
8+
query_params: "MultiDict[str, str]", model: Type[BaseModel]
9+
) -> Dict[str, Union[str, List[str]]]:
1010
"""
1111
group query parameters into lists if model defines them
1212

0 commit comments

Comments
 (0)