Merge pull request #3972 from ThiefMaster/click-7
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Allow using Click 7 with a DeprecationWarning
authored by David Lord · committed by GitHub · parents 1ccf063, 26a6cc0 · Browse files · 5 files·+26 added−3 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
5 files+26 added−3 removed
- tests:+10 added−0 removed
- other:+16 added−3 removed
Provenance
- Commit
77db3d5- Tree
563d9d2- Author
David Lord <davidism@gmail.com>- Committer
GitHub <noreply@github.com>- Parent 1
1ccf063- Parent 2
26a6cc0
5 files changed+26 added−3 removed
modified:src/flask/cli.py+7 added
977 unmodified lines978 )979 980 981 def main() -> None:982+ if int(click.__version__[0]) < 8:983+ warnings.warn(984+ "Using the `flask` cli with Click 7 is deprecated and"985+ " will not be supported starting with Flask 2.1."986+ " Please upgrade to Click 8 as soon as possible.",987+ DeprecationWarning,988+ )989 # TODO omit sys.argv once https://github.com/pallets/click/issues/536 is fixed990 cli.main(args=sys.argv[1:])991 992 2 unmodified linesmodified:tests/test_cli.py+10 added
3 unmodified lines4 import ssl5 import sys6 import types7 from functools import partial8+from unittest.mock import patch9 10 import click11 import pytest12 from _pytest.monkeypatch import notset8 unmodified lines21 from flask.cli import FlaskGroup22 from flask.cli import get_version23 from flask.cli import load_dotenv24 from flask.cli import locate_app25+from flask.cli import main as cli_main26 from flask.cli import NoAppException27 from flask.cli import prepare_import28 from flask.cli import run_command29 from flask.cli import ScriptInfo631 unmodified lines661 app.register_blueprint(bp)662 663 result = app.test_cli_runner().invoke(args=["blue", "--help"])664 assert result.exit_code == 2, f"Unexpected success:\n\n{result.output}"665+666+667+def test_click_7_deprecated():668+ with patch("flask.cli.cli"):669+ if int(click.__version__[0]) < 8:670+ pytest.deprecated_call(cli_main, match=".* Click 7 is deprecated")671+ else:672+ cli_main()modified:CHANGES.rst+4 added-1 removed
6 unmodified lines7 8 - Drop support for Python 2 and 3.5.9 - Bump minimum versions of other Pallets projects: Werkzeug >= 2,10 Jinja2 >= 3, MarkupSafe >= 2, ItsDangerous >= 2, Click >= 8. Be sure11- to check the change logs for each project.11+ to check the change logs for each project. For better compatibility12+ with other applications (e.g. Celery) that still require Click 7,13+ there is no hard dependency on Click 8 yet, but using Click 7 will14+ trigger a DeprecationWarning and Flask 2.1 will depend on Click 8.15 - JSON support no longer uses simplejson. To use another JSON module,16 override ``app.json_encoder`` and ``json_decoder``. :issue:`3555`17 - The ``encoding`` option to JSON functions is deprecated. :pr:`3562`18 - Passing ``script_info`` to app factory functions is deprecated. This1080 unmodified linesmodified:setup.py+1 added-1 removed
5 unmodified lines6 install_requires=[7 "Werkzeug>=2.0.0rc4",8 "Jinja2>=3.0.0rc1",9 "itsdangerous>=2.0.0rc2",10- "click>=8.0.0rc1",10+ "click>=7.1.2",11 ],12 extras_require={13 "async": ["asgiref>=3.2"],14 "dotenv": ["python-dotenv"],2 unmodified linesmodified:tox.ini+4 added-1 removed
1 [tox]2 envlist =3 py{39,38,37,36,py3}4+ py39-click75 style6 typing7 docs8 skip_missing_interpreters = true5 unmodified lines14 https://github.com/pallets/werkzeug/archive/master.tar.gz15 https://github.com/pallets/markupsafe/archive/master.tar.gz16 https://github.com/pallets/jinja/archive/master.tar.gz17 https://github.com/pallets/itsdangerous/archive/master.tar.gz17- https://github.com/pallets/click/archive/master.tar.gz18 19+ !click7: https://github.com/pallets/click/archive/master.tar.gz20+ click7: click<821+22 examples/tutorial[test]23 examples/javascript[test]24 commands = pytest -v --tb=short --basetemp={envtmpdir} {posargs:tests examples}25 15 unmodified lines