Fixes Pyright type errors for src/flask/blueprint.py

This commit is contained in:
bre-17387639 2024-08-06 17:18:34 -06:00
parent 8a6cdf1e2a
commit 06b3125207
2 changed files with 3 additions and 1 deletions

View file

@ -6,6 +6,7 @@ Version 3.1.0
- ``Flask.open_resource``/``open_instance_resource`` and - ``Flask.open_resource``/``open_instance_resource`` and
``Blueprint.open_resource`` take an ``encoding`` parameter to use when ``Blueprint.open_resource`` take an ``encoding`` parameter to use when
opening in text mode. It defaults to ``utf-8``. :issue:`5504` opening in text mode. It defaults to ``utf-8``. :issue:`5504`
- Fixes Pyright type errors in ``src/flask/blueprint.py``. :issue:`5545`
Version 3.0.3 Version 3.0.3
------------- -------------

View file

@ -3,6 +3,7 @@ from __future__ import annotations
import os import os
import typing as t import typing as t
from datetime import timedelta from datetime import timedelta
from io import BufferedReader
from .cli import AppGroup from .cli import AppGroup
from .globals import current_app from .globals import current_app
@ -103,7 +104,7 @@ class Blueprint(SansioBlueprint):
def open_resource( def open_resource(
self, resource: str, mode: str = "rb", encoding: str | None = "utf-8" self, resource: str, mode: str = "rb", encoding: str | None = "utf-8"
) -> t.IO[t.AnyStr]: ) -> t.IO[t.AnyStr] | BufferedReader:
"""Open a resource file relative to :attr:`root_path` for reading. The """Open a resource file relative to :attr:`root_path` for reading. The
blueprint-relative equivalent of the app's :meth:`~.Flask.open_resource` blueprint-relative equivalent of the app's :meth:`~.Flask.open_resource`
method. method.