Issue 1:
I override Response.force_type to handle my own custom responses (and some extra builtin types like lists). I recently tried to upgrade to Flask==1.1.x but it no longer calls my handler and throws an exception instead.

Reproduce

import pytest
from flask import Flask, Response, jsonify

class MyCustomType:
def to_json(self):
return {'ok': 1}

class MyResponse(Response):
@classmethod
def force_type(cls, response, environ=None):
if isinstance(response, list):
return jsonify(response)
if isinstance(response, MyCustomType):
return jsonify(response.to_json())
return super(MyResponse, cls).force_type(response, environ=environ)

class MyApp(Flask):
response_class = MyResponse

my_app = MyApp(__name__)

@my_app.route('/list')
def get_list():
return ['my_element']

@my_app.route('/my')
def get_my():
return MyCustomType()

@pytest.fixture
def client():
with my_app.test_client() as client:
yield client

def test_force_type_list(client):
assert client.get('/list').json == ['my_element']

def test_force_type_my(client):
assert client.get('/my').json == {'ok': 1}

Exception

Traceback (most recent call last):
File "/home/closeio/venv/lib/python3.6/site-packages/flask/app.py", line 2446, in wsgi_app
response = self.full_dispatch_request()
File "/home/closeio/venv/lib/python3.6/site-packages/flask/app.py", line 1952, in full_dispatch_request
return self.finalize_request(rv)
File "/home/closeio/venv/lib/python3.6/site-packages/flask/app.py", line 1967, in finalize_request
response = self.make_response(rv)
File "/home/closeio/venv/lib/python3.6/site-packages/flask/app.py", line 2130, in make_response
" {rv.__class__.__name__}.".format(rv=rv)
TypeError: The view function did not return a valid response. The return type must be a string, dict, tuple, Response instance, or WSGI callable, but it was a MyCustomType.

Environment

Python version: 3.6.9

Flask version: 1.1.4 (it works on 1.0.4)

Werkzeug version: 0.15.6

PR that caused the issue

#3235

Issue 2:
When using flask 2.0.2 and having an error in the import the flask cli does not output the traceback anymore.

It seems to have stopped to work after #4283 was merged.

To reproduce: make an import error and run:

(.venv) PS D:\Workspace\private\notifications\python-api> flask run --debugger --reload
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
Usage: flask run [OPTIONS]
Try 'flask run --help' for help.

Error: While importing 'wsgi', an ImportError was raised.

Expected the following traceback:

Python 3.10.2 (tags/v3.10.2:a58ebcc, Jan 17 2022, 14:12:15) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from gna import create_app
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\Workspace\private\notifications\python-api\gna\__init__.py", line 4, in <module>
from . import models, routes, services
File "D:\Workspace\private\notifications\python-api\gna\routes\__init__.py", line 4, in <module>
from .api import api_bp
ImportError: cannot import name 'api_bp' from 'gna.routes.api' (D:\Workspace\private\notifications\python-api\gna\routes\api\__init__.py)
>>>

Environment:

Python version: 3.10.2

Flask version: 2.0.2