cex-solutions / types-smorest

GNU General Public License v3.0
2 stars 0 forks source link

Typing issue with instances of subclasses of `Blueprint` #105

Open dbnl-tjs opened 1 month ago

dbnl-tjs commented 1 month ago

Hi, I am trying to extend the Blueprint class with my own functionality. Mypy is not happy with typing in the following example. The revealed type for MySmorestBlueprint should be example.MySmorestBlueprint, not flask_smorest.blueprint.Blueprint.

(venv) bash-3.2$ cat example.py
from flask import Blueprint as FlaskBlueprint
from flask_smorest.blueprint import Blueprint as SmorestBlueprint

class MyFlaskBlueprint(FlaskBlueprint):
    pass

class MySmorestBlueprint(SmorestBlueprint):
    pass

reveal_type(MyFlaskBlueprint("", ""))
reveal_type(MySmorestBlueprint("", ""))
(venv) bash-3.2$ mypy example.py
example.py:10: note: Revealed type is "example.MyFlaskBlueprint"
example.py:11: note: Revealed type is "flask_smorest.blueprint.Blueprint"
Success: no issues found in 1 source file
(venv) bash-3.2$ pip list
Package           Version
----------------- -------
apispec           6.6.1
blinker           1.8.2
click             8.1.7
Flask             3.0.3
flask-smorest     0.44.0
itsdangerous      2.2.0
Jinja2            3.1.4
MarkupSafe        2.1.5
marshmallow       3.22.0
mypy              1.11.2
mypy-extensions   1.0.0
packaging         24.1
pip               23.2.1
setuptools        65.5.0
types-smorest     1.1.2
typing_extensions 4.12.2
webargs           8.6.0
Werkzeug          3.0.4

[notice] A new release of pip is available: 23.2.1 -> 24.2
[notice] To update, run: pip install --upgrade pip
(venv) bash-3.2$ python --version
Python 3.11.6
dbnl-tjs commented 1 month ago

Seems to be an issue with empty stubs in https://github.com/cex-solutions/types-smorest/blob/main/flask_smorest-stubs/etag.pyi and https://github.com/cex-solutions/types-smorest/blob/main/flask_smorest-stubs/pagination.pyi