Skip to content

Conversation

@lecovi
Copy link
Contributor

@lecovi lecovi commented May 2, 2022

Examples of typing for:

  • String view
  • JSON view
  • Error Handler
  • Before Request
  • Class Based View

fixes #4574

@davidism
Copy link
Member

davidism commented May 2, 2022

Does mypy check this file when running the typing test env?

@lecovi
Copy link
Contributor Author

lecovi commented May 2, 2022

This solves #4574

@lecovi
Copy link
Contributor Author

lecovi commented May 2, 2022

@davidism Yes, It does! 👍🏽
Screen Shot 2022-05-02 at 16 17 33

@davidism davidism force-pushed the docs/#4574-test-typing branch from ecf2eb0 to 3351a86 Compare June 5, 2022 22:45
@davidism davidism changed the base branch from main to 2.1.x June 5, 2022 22:45
@davidism davidism added the typing label Jun 5, 2022
@davidism
Copy link
Member

davidism commented Jun 5, 2022

I moved these from the examples to tests directory, and added the directory to the mypy config so that they are tested automatically. I also did some refactoring to organize additional tests in the future.

Based on your @app.route tests, I realized that the decorated functions weren't actually being type checked. I've adjusted the type definitions, so now a view function that is annotated with an invalid return value will actually fail to type check.

I reported two issues to mypy while working on this:

@davidism davidism merged commit fb89745 into pallets:2.1.x Jun 5, 2022
@davidism davidism added this to the 2.1.3 milestone Jun 5, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test typing

2 participants