ssfdust / flask-sqlalchemy-stubs

testing stubs and mypy plugin for flask-sqlalchemy
36 stars 20 forks source link

mypy failing in examples using filter_by and other functions #3

Open noahskelton opened 4 years ago

noahskelton commented 4 years ago

mypy doesn't pass using the examples in this repo in my environment.

Steps to reproduce using Python 3.8.5:

  1. Clone this repo
  2. pip install .
  3. mypy examples

Output:

examples/sample.py:31: error: Incompatible type for argument "name" (got "int", expected "Optional[str]")
examples/sample.py:32: error: Call to untyped function "filter_by" in typed context
examples/sample.py:37: error: Call to untyped function "filter_by" in typed context
Found 3 errors in 1 file (checked 4 source files)

I get similar issues in my project.

ssfdust commented 4 years ago

Flask-sqlalchemy-stubs depends on sqlalchemy-stubs. The filter_by function is located in sqlalchemy-stubs, I can't fix it. Since there're a lot of untyped functions in sqlalchemy-stubs, I recommand you to enable the option which allows untyped calls in mypy. Here's my mypy.ini on my work. https://github.com/ssfdust/smorest-sfs/blob/master/mypy.ini