diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3ef408f8..a78c1719 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,11 +14,11 @@ repos: files: "^(?!examples/)" args: ["--application-directories", "src"] - repo: https://github.com/psf/black - rev: 21.9b0 + rev: 21.10b0 hooks: - id: black - repo: https://github.com/PyCQA/flake8 - rev: 3.9.2 + rev: 4.0.1 hooks: - id: flake8 additional_dependencies: diff --git a/docs/config.rst b/docs/config.rst index 768cf60d..ad737109 100644 --- a/docs/config.rst +++ b/docs/config.rst @@ -38,7 +38,7 @@ method:: app.config.update( TESTING=True, - SECRET_KEY=b'_5#y2L"F4Q8z\n\xec]/' + SECRET_KEY='192b9bdd22ab9ed4d12e236c78afcb9a393ec15f71bbf5dc987d54727823bcbf' ) @@ -180,8 +180,8 @@ The following configuration values are used internally by Flask: application. It should be a long random ``bytes`` or ``str``. For example, copy the output of this to your config:: - $ python -c 'import os; print(os.urandom(16))' - b'_5#y2L"F4Q8z\n\xec]/' + $ python -c 'import secrets; print(secrets.token_hex())' + '192b9bdd22ab9ed4d12e236c78afcb9a393ec15f71bbf5dc987d54727823bcbf' **Do not reveal the secret key when posting questions or committing code.** @@ -468,7 +468,7 @@ sure to use uppercase letters for your config keys. Here is an example of a configuration file:: # Example configuration - SECRET_KEY = b'_5#y2L"F4Q8z\n\xec]/' + SECRET_KEY = '192b9bdd22ab9ed4d12e236c78afcb9a393ec15f71bbf5dc987d54727823bcbf' Make sure to load the configuration very early on, so that extensions have the ability to access the configuration when starting up. There are other diff --git a/docs/patterns/sqlite3.rst b/docs/patterns/sqlite3.rst index 8cf596d3..12336fb1 100644 --- a/docs/patterns/sqlite3.rst +++ b/docs/patterns/sqlite3.rst @@ -113,16 +113,16 @@ raw cursor and connection objects. Here is how you can use it:: for user in query_db('select * from users'): - print user['username'], 'has the id', user['user_id'] + print(user['username'], 'has the id', user['user_id']) Or if you just want a single result:: user = query_db('select * from users where username = ?', [the_username], one=True) if user is None: - print 'No such user' + print('No such user') else: - print the_username, 'has the id', user['user_id'] + print(the_username, 'has the id', user['user_id']) To pass variable parts to the SQL statement, use a question mark in the statement and pass in the arguments as a list. Never directly add them to diff --git a/docs/quickstart.rst b/docs/quickstart.rst index 179c4103..9bddbfc0 100644 --- a/docs/quickstart.rst +++ b/docs/quickstart.rst @@ -847,8 +847,8 @@ sessions work:: generator. Use the following command to quickly generate a value for :attr:`Flask.secret_key` (or :data:`SECRET_KEY`):: - $ python -c 'import os; print(os.urandom(16))' - b'_5#y2L"F4Q8z\n\xec]/' + $ python -c 'import secrets; print(secrets.token_hex())' + '192b9bdd22ab9ed4d12e236c78afcb9a393ec15f71bbf5dc987d54727823bcbf' A note on cookie-based sessions: Flask will take the values you put into the session object and serialize them into a cookie. If you are finding some diff --git a/docs/signals.rst b/docs/signals.rst index 1e5cdd65..27630de6 100644 --- a/docs/signals.rst +++ b/docs/signals.rst @@ -177,7 +177,7 @@ With Blinker 1.1 you can also easily subscribe to signals by using the new @template_rendered.connect_via(app) def when_template_rendered(sender, template, context, **extra): - print f'Template {template.name} is rendered with {context}' + print(f'Template {template.name} is rendered with {context}') Core Signals ------------ diff --git a/docs/tutorial/deploy.rst b/docs/tutorial/deploy.rst index d954b5e7..19aa87fc 100644 --- a/docs/tutorial/deploy.rst +++ b/docs/tutorial/deploy.rst @@ -88,9 +88,9 @@ You can use the following command to output a random secret key: .. code-block:: none - $ python -c 'import os; print(os.urandom(16))' + $ python -c 'import secrets; print(secrets.token_hex())' - b'_5#y2L"F4Q8z\n\xec]/' + '192b9bdd22ab9ed4d12e236c78afcb9a393ec15f71bbf5dc987d54727823bcbf' Create the ``config.py`` file in the instance folder, which the factory will read from if it exists. Copy the generated value into it. @@ -98,7 +98,7 @@ will read from if it exists. Copy the generated value into it. .. code-block:: python :caption: ``venv/var/flaskr-instance/config.py`` - SECRET_KEY = b'_5#y2L"F4Q8z\n\xec]/' + SECRET_KEY = '192b9bdd22ab9ed4d12e236c78afcb9a393ec15f71bbf5dc987d54727823bcbf' You can also set any other necessary configuration here, although ``SECRET_KEY`` is the only one needed for Flaskr. diff --git a/requirements/dev.txt b/requirements/dev.txt index 19f50095..12c81edd 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -1,5 +1,5 @@ # -# This file is autogenerated by pip-compile with python 3.9 +# This file is autogenerated by pip-compile with python 3.10 # To update, run: # # pip-compile requirements/dev.in @@ -16,15 +16,15 @@ backports.entry-points-selectable==1.1.0 # via virtualenv blinker==1.4 # via -r requirements/tests.in -certifi==2021.5.30 +certifi==2021.10.8 # via requests -cffi==1.14.6 +cffi==1.15.0 # via cryptography cfgv==3.3.1 # via pre-commit -charset-normalizer==2.0.6 +charset-normalizer==2.0.7 # via requests -click==8.0.1 +click==8.0.3 # via pip-tools cryptography==35.0.0 # via -r requirements/typing.in @@ -34,21 +34,21 @@ docutils==0.16 # via # sphinx # sphinx-tabs -filelock==3.2.0 +filelock==3.3.2 # via # tox # virtualenv greenlet==1.1.2 # via -r requirements/tests.in -identify==2.2.15 +identify==2.3.3 # via pre-commit -idna==3.2 +idna==3.3 # via requests imagesize==1.2.0 # via sphinx iniconfig==1.1.1 # via pytest -jinja2==3.0.1 +jinja2==3.0.2 # via sphinx markupsafe==2.0.1 # via jinja2 @@ -58,7 +58,7 @@ mypy-extensions==0.4.3 # via mypy nodeenv==1.6.0 # via pre-commit -packaging==21.0 +packaging==21.2 # via # pallets-sphinx-themes # pytest @@ -66,9 +66,9 @@ packaging==21.0 # tox pallets-sphinx-themes==2.0.1 # via -r requirements/docs.in -pep517==0.11.0 +pep517==0.12.0 # via pip-tools -pip-tools==6.3.0 +pip-tools==6.4.0 # via -r requirements/dev.in platformdirs==2.4.0 # via virtualenv @@ -92,11 +92,11 @@ pyparsing==2.4.7 # via packaging pytest==6.2.5 # via -r requirements/tests.in -python-dotenv==0.19.0 +python-dotenv==0.19.1 # via -r requirements/tests.in -pytz==2021.1 +pytz==2021.3 # via babel -pyyaml==5.4.1 +pyyaml==6.0 # via pre-commit requests==2.26.0 # via sphinx @@ -137,21 +137,21 @@ toml==0.10.2 # pre-commit # pytest # tox -tomli==1.2.1 +tomli==1.2.2 # via pep517 tox==3.24.4 # via -r requirements/dev.in -types-contextvars==0.1.4 +types-contextvars==2.4.0 # via -r requirements/typing.in -types-dataclasses==0.1.7 +types-dataclasses==0.6.1 # via -r requirements/typing.in -types-setuptools==57.4.0 +types-setuptools==57.4.2 # via -r requirements/typing.in typing-extensions==3.10.0.2 # via mypy urllib3==1.26.7 # via requests -virtualenv==20.8.1 +virtualenv==20.10.0 # via # pre-commit # tox diff --git a/requirements/docs.txt b/requirements/docs.txt index 43b83f93..8f5fd06a 100644 --- a/requirements/docs.txt +++ b/requirements/docs.txt @@ -1,5 +1,5 @@ # -# This file is autogenerated by pip-compile with python 3.9 +# This file is autogenerated by pip-compile with python 3.10 # To update, run: # # pip-compile requirements/docs.in @@ -8,23 +8,23 @@ alabaster==0.7.12 # via sphinx babel==2.9.1 # via sphinx -certifi==2021.5.30 +certifi==2021.10.8 # via requests -charset-normalizer==2.0.6 +charset-normalizer==2.0.7 # via requests docutils==0.16 # via # sphinx # sphinx-tabs -idna==3.2 +idna==3.3 # via requests imagesize==1.2.0 # via sphinx -jinja2==3.0.1 +jinja2==3.0.2 # via sphinx markupsafe==2.0.1 # via jinja2 -packaging==21.0 +packaging==21.2 # via # pallets-sphinx-themes # sphinx @@ -36,7 +36,7 @@ pygments==2.10.0 # sphinx-tabs pyparsing==2.4.7 # via packaging -pytz==2021.1 +pytz==2021.3 # via babel requests==2.26.0 # via sphinx diff --git a/requirements/tests.txt b/requirements/tests.txt index 11889378..41e66b76 100644 --- a/requirements/tests.txt +++ b/requirements/tests.txt @@ -1,5 +1,5 @@ # -# This file is autogenerated by pip-compile with python 3.9 +# This file is autogenerated by pip-compile with python 3.10 # To update, run: # # pip-compile requirements/tests.in @@ -14,7 +14,7 @@ greenlet==1.1.2 # via -r requirements/tests.in iniconfig==1.1.1 # via pytest -packaging==21.0 +packaging==21.2 # via pytest pluggy==1.0.0 # via pytest @@ -24,7 +24,7 @@ pyparsing==2.4.7 # via packaging pytest==6.2.5 # via -r requirements/tests.in -python-dotenv==0.19.0 +python-dotenv==0.19.1 # via -r requirements/tests.in toml==0.10.2 # via pytest diff --git a/requirements/typing.txt b/requirements/typing.txt index 724aa2a2..2be7465a 100644 --- a/requirements/typing.txt +++ b/requirements/typing.txt @@ -1,10 +1,10 @@ # -# This file is autogenerated by pip-compile with python 3.9 +# This file is autogenerated by pip-compile with python 3.10 # To update, run: # # pip-compile requirements/typing.in # -cffi==1.14.6 +cffi==1.15.0 # via cryptography cryptography==35.0.0 # via -r requirements/typing.in @@ -16,11 +16,11 @@ pycparser==2.20 # via cffi toml==0.10.2 # via mypy -types-contextvars==0.1.4 +types-contextvars==2.4.0 # via -r requirements/typing.in -types-dataclasses==0.1.7 +types-dataclasses==0.6.1 # via -r requirements/typing.in -types-setuptools==57.4.0 +types-setuptools==57.4.2 # via -r requirements/typing.in typing-extensions==3.10.0.2 # via mypy