Issue 1:
Summary:

Auto-reload on the development server is triggered by requests (i.e. file reads) without a file modification happening.

How to reproduce:

Any Flask project, having installed Watchdog version >= 2.3.0. Send a request to any endpoint.

Expected behavior:

When sending a request to the server, the server answers and doesn't get reloaded unless a file is modified.

My assumption is that the new event FileOpenedEvent added in 2.3.0 is being treated as a file modification and triggering auto-reload. Forcing watchdog version 2.2.1 fixed the problem.

Environment:

Python version: 3.8

Flask version: 2.2.2

Issue 2:
With Flask 2.1.0 :

$ flask test
=========================================================================== test session starts ============================================================================
platform darwin -- Python 3.10.3, pytest-7.1.2, pluggy-1.0.0 -- /Users/antoine/Documents/Git/portail/venv/bin/python3
cachedir: .pytest_cache
rootdir: /Users/antoine/Documents/Git/portail
collected 29 items
...
===================================================================== 29 passed, 5 warnings in 15.65s ======================================================================

With Flask 2.2.0 :

=========================================================================== test session starts ============================================================================
platform darwin -- Python 3.10.3, pytest-7.1.2, pluggy-1.0.0 -- /Users/antoine/Documents/Git/portail/venv/bin/python3
cachedir: .pytest_cache
rootdir: /Users/antoine/Documents/Git/portail
collected 29 items

test/test_accessibility.py::TestAccessibility::test_admin_accessibility ERROR
test/test_accessibility.py::TestAccessibility::test_client_accessibility ERROR
...
========================================================================= short test summary info ==========================================================================
ERROR test/test_accessibility.py::TestAccessibility::test_admin_accessibility - sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: cre_module
ERROR test/test_accessibility.py::TestAccessibility::test_client_accessibility - sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: cre_module

My tables are not created in Flask 2.2.0

However I didn't change anything in my tests and I don't see anything in the changelog that could affect the tests.

The errors happen only when I change the version of Flask (2.1.3 --> 2.2.0).

Here is the code that creates the tables (which works in 2.1.3 but not in 2.2.0).

from portail import create_app
from portail.modules import PORTAIL_MODULES, detect_modules
from portail.database import db as _db
from portail.settings import TestConfig

@pytest.fixture()
def app():
"""An application for the tests."""
_app = create_app(TestConfig())

with _app.app_context():
_db.create_all()
modules = detect_modules()
for m in modules:
m.save(False)
_db.session.commit()
for m in modules:
PORTAIL_MODULES[m.id] = m
m.expunge()

ctx = _app.test_request_context()
ctx.push()

yield _app

ctx.pop()

with _app.app_context():
_db.drop_all()

@pytest.fixture()
def db(app):
"""A database for the tests."""
_db.app = app
with app.app_context():
_db.create_all()

yield _db

# Explicitly close DB connection
_db.session.close()
_db.drop_all()

Has app.app_context() been modified or something I use for database setup?

Environment:

Python version: 3.10.3

Flask version: 2.2.0