Skip to content

Commit

Permalink
Improve typing in the module
Browse files Browse the repository at this point in the history
Fixes bauerji#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]>
  • Loading branch information
MarekPikula committed Apr 18, 2023
1 parent 064976a commit f6c2afc
Show file tree
Hide file tree
Showing 7 changed files with 192 additions and 116 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,26 @@ name: Tests
on: [push, pull_request]

jobs:
mypy:
runs-on: ubuntu-latest
strategy:
fail-fast: false

steps:
- uses: actions/checkout@v1
- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: "3.7"
- name: Install dependencies
if: steps.cache-pip.outputs.cache-hit != 'true'
run: |
python -m pip install --upgrade pip
pip install -r requirements/test.pip
- name: Run mypy satic check
run: |
python3 -m mypy flask_pydantic/
build:
runs-on: ${{ matrix.os }}
strategy:
Expand Down
8 changes: 4 additions & 4 deletions flask_pydantic/converters.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from typing import Type
from typing import Dict, List, Type, Union

from pydantic import BaseModel
from werkzeug.datastructures import ImmutableMultiDict
from werkzeug.datastructures import MultiDict


def convert_query_params(
query_params: ImmutableMultiDict, model: Type[BaseModel]
) -> dict:
query_params: "MultiDict[str, str]", model: Type[BaseModel]
) -> Dict[str, Union[str, List[str]]]:
"""
group query parameters into lists if model defines them
Expand Down
Loading

0 comments on commit f6c2afc

Please sign in to comment.