@@ -126,6 +126,16 @@ def unpack(response, default_code=HTTPStatus.OK):
126
126
raise ValueError ("Too many response values" )
127
127
128
128
129
+ def to_view_name (view_func : typing .Callable ) -> str :
130
+ """Helper that returns the default endpoint for a given
131
+ function. This always is the function name.
132
+
133
+ Note: copy of simple flask internal helper
134
+ """
135
+ assert view_func is not None , "expected view func if endpoint is not provided."
136
+ return view_func .__name__
137
+
138
+
129
139
def import_check_view_func ():
130
140
"""
131
141
Resolve import flask _endpoint_from_view_func.
@@ -138,14 +148,6 @@ def import_check_view_func():
138
148
import importlib .metadata
139
149
140
150
flask_version = importlib .metadata .version ("flask" ).split ("." )
141
-
142
- def local_endpoint_from_view_func (view_func : typing .Callable ) -> str :
143
- """Copy of flask internal helper that returns the default endpoint for a given
144
- function. This always is the function name.
145
- """
146
- assert view_func is not None , "expected view func if endpoint is not provided."
147
- return view_func .__name__
148
-
149
151
try :
150
152
if flask_version [0 ] == "1" :
151
153
from flask .helpers import _endpoint_from_view_func
@@ -160,5 +162,5 @@ def local_endpoint_from_view_func(view_func: typing.Callable) -> str:
160
162
warnings .simplefilter ("once" , FlaskCompatibilityWarning )
161
163
_endpoint_from_view_func = None
162
164
if _endpoint_from_view_func is None :
163
- _endpoint_from_view_func = local_endpoint_from_view_func
165
+ _endpoint_from_view_func = to_view_name
164
166
return _endpoint_from_view_func
0 commit comments