21.6 Changelog, release version, and deprecations (#2172)

* Changelog and version

* Rearrange API docs for easier navigation

* Version 21.6 docs

* Change release workflow

* Disable Windows tests
This commit is contained in:
Adam Hopkins 2021-06-27 22:52:56 +03:00 committed by GitHub
parent 53da4dd091
commit 30572c972d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 318 additions and 197 deletions

View File

@ -1,34 +1,34 @@
name: Run Unit Tests on Windows # name: Run Unit Tests on Windows
on: # on:
pull_request: # pull_request:
branches: # branches:
- main # - main
jobs: # jobs:
testsOnWindows: # testsOnWindows:
name: ut-${{ matrix.config.tox-env }} # name: ut-${{ matrix.config.tox-env }}
runs-on: windows-latest # runs-on: windows-latest
strategy: # strategy:
fail-fast: false # fail-fast: false
matrix: # matrix:
config: # config:
- { python-version: 3.7, tox-env: py37-no-ext } # - { python-version: 3.7, tox-env: py37-no-ext }
- { python-version: 3.8, tox-env: py38-no-ext } # - { python-version: 3.8, tox-env: py38-no-ext }
- { python-version: 3.9, tox-env: py39-no-ext } # - { python-version: 3.9, tox-env: py39-no-ext }
- { python-version: pypy-3.7, tox-env: pypy37-no-ext } # - { python-version: pypy-3.7, tox-env: pypy37-no-ext }
steps: # steps:
- name: Checkout Repository # - name: Checkout Repository
uses: actions/checkout@v2 # uses: actions/checkout@v2
- name: Run Unit Tests # - name: Run Unit Tests
uses: ahopkins/custom-actions@pip-extra-args # uses: ahopkins/custom-actions@pip-extra-args
with: # with:
python-version: ${{ matrix.config.python-version }} # python-version: ${{ matrix.config.python-version }}
test-infra-tool: tox # test-infra-tool: tox
test-infra-version: latest # test-infra-version: latest
action: tests # action: tests
test-additional-args: "-e=${{ matrix.config.tox-env }}" # test-additional-args: "-e=${{ matrix.config.tox-env }}"
experimental-ignore-error: "true" # experimental-ignore-error: "true"
command-timeout: "600000" # command-timeout: "600000"
pip-extra-args: "--user" # pip-extra-args: "--user"

View File

@ -1,8 +1,8 @@
name: Publish Artifacts name: Publish Artifacts
on: on:
push: release:
tags: types: [created]
- 'v*.*.*'
jobs: jobs:
publishPythonPackage: publishPythonPackage:
name: Publishing Sanic Release Artifacts name: Publishing Sanic Release Artifacts
@ -21,8 +21,8 @@ jobs:
uses: harshanarayana/custom-actions@main uses: harshanarayana/custom-actions@main
with: with:
python-version: ${{ matrix.python-version }} python-version: ${{ matrix.python-version }}
package-infra-name: 'twine' package-infra-name: "twine"
pypi-user: __token__ pypi-user: __token__
pypi-access-token: ${{ secrets.PYPI_ACCESS_TOKEN }} pypi-access-token: ${{ secrets.PYPI_ACCESS_TOKEN }}
action: 'package-publish' action: "package-publish"
pypi-verify-metadata: 'true' pypi-verify-metadata: "true"

View File

@ -1,3 +1,95 @@
Version 21.6.0
--------------
Features
********
* `#2094 <https://github.com/sanic-org/sanic/pull/2094>`_
Add ``response.eof()`` method for closing a stream in a handler
* `#2097 <https://github.com/sanic-org/sanic/pull/2097>`_
Allow case-insensitive HTTP Upgrade header
* `#2104 <https://github.com/sanic-org/sanic/pull/2104>`_
Explicit usage of CIMultiDict getters
* `#2109 <https://github.com/sanic-org/sanic/pull/2109>`_
Consistent use of error loggers
* `#2114 <https://github.com/sanic-org/sanic/pull/2114>`_
New ``client_ip`` access of connection info instance
* `#2119 <https://github.com/sanic-org/sanic/pull/2119>`_
Alternatate classes on instantiation for ``Config`` and ``Sanic.ctx``
* `#2133 <https://github.com/sanic-org/sanic/pull/2133>`_
Implement new version of AST router
* Proper differentiation between ``alpha`` and ``string`` param types
* Adds a ``slug`` param type, example: ``<foo:slug>``
* Deprecates ``<foo:string>`` in favor of ``<foo:str>``
* Deprecates ``<foo:number>`` in favor of ``<foo:float>``
* Adds a ``route.uri`` accessor
* `#2136 <https://github.com/sanic-org/sanic/pull/2136>`_
CLI improvements with new optional params
* `#2137 <https://github.com/sanic-org/sanic/pull/2137>`_
Add ``version_prefix`` to URL builders
* `#2140 <https://github.com/sanic-org/sanic/pull/2140>`_
Event autoregistration with ``EVENT_AUTOREGISTER``
* `#2146 <https://github.com/sanic-org/sanic/pull/2146>`_, `#2147 <https://github.com/sanic-org/sanic/pull/2147>`_
Require stricter names on ``Sanic()`` and ``Blueprint()``
* `#2150 <https://github.com/sanic-org/sanic/pull/2150>`_
Infinitely reusable and nestable ``Blueprint`` and ``BlueprintGroup``
* `#2154 <https://github.com/sanic-org/sanic/pull/2154>`_
Upgrade ``websockets`` dependency to min version
* `#2155 <https://github.com/sanic-org/sanic/pull/2155>`_
Allow for maximum header sizes to be increased: ``REQUEST_MAX_HEADER_SIZE``
* `#2157 <https://github.com/sanic-org/sanic/pull/2157>`_
Allow app factory pattern in CLI
* `#2165 <https://github.com/sanic-org/sanic/pull/2165>`_
Change HTTP methods to enums
* `#2167 <https://github.com/sanic-org/sanic/pull/2167>`_
Allow auto-reloading on additional directories
* `#2168 <https://github.com/sanic-org/sanic/pull/2168>`_
Add simple HTTP server to CLI
* `#2170 <https://github.com/sanic-org/sanic/pull/2170>`_
Additional methods for attaching ``HTTPMethodView``
Bugfixes
********
* `#2091 <https://github.com/sanic-org/sanic/pull/2091>`_
Fix ``UserWarning`` in ASGI mode for missing ``__slots__``
* `#2099 <https://github.com/sanic-org/sanic/pull/2099>`_
Fix static request handler logging exception on 404
* `#2110 <https://github.com/sanic-org/sanic/pull/2110>`_
Fix request.args.pop removes parameters inconsistently
* `#2107 <https://github.com/sanic-org/sanic/pull/2107>`_
Fix type hinting for load_env
* `#2127 <https://github.com/sanic-org/sanic/pull/2127>`_
Make sure ASGI ws subprotocols is a list
* `#2128 <https://github.com/sanic-org/sanic/pull/2128>`_
Fix issue where Blueprint exception handlers do not consistently route to proper handler
Deprecations and Removals
*************************
* `#2156 <https://github.com/sanic-org/sanic/pull/2156>`_
Remove config value ``REQUEST_BUFFER_QUEUE_SIZE``
* `#2170 <https://github.com/sanic-org/sanic/pull/2170>`_
``CompositionView`` deprecated and marked for removal in 21.12
* `#2172 <https://github.com/sanic-org/sanic/pull/2170>`_
Deprecate StreamingHTTPResponse
Developer infrastructure
************************
* `#2149 <https://github.com/sanic-org/sanic/pull/2149>`_
Remove Travis CI in favor of GitHub Actions
Improved Documentation
**********************
* `#2164 <https://github.com/sanic-org/sanic/pull/2164>`_
Fix typo in documentation
* `#2100 <https://github.com/sanic-org/sanic/pull/2100>`_
Remove documentation for non-existent arguments
Version 21.3.2 Version 21.3.2
-------------- --------------

View File

@ -87,7 +87,7 @@ Permform ``flake8``\ , ``black`` and ``isort`` checks.
tox -e lint tox -e lint
Run type annotation checks Run type annotation checks
--------------- --------------------------
``tox`` environment -> ``[testenv:type-checking]`` ``tox`` environment -> ``[testenv:type-checking]``

View File

@ -88,8 +88,7 @@ docs-test: docs-clean
cd docs && make dummy cd docs && make dummy
docs-serve: docs-serve:
# python -m http.server --directory=./docs/_build/html 9999 sphinx-autobuild docs docs/_build/html --port 9999 --watch ./
sphinx-autobuild docs docs/_build/html --port 9999 --watch ./sanic
changelog: changelog:
python scripts/changelog.py python scripts/changelog.py

17
docs/sanic/api/app.rst Normal file
View File

@ -0,0 +1,17 @@
Application
===========
sanic.app
---------
.. automodule:: sanic.app
:members:
:show-inheritance:
:inherited-members:
sanic.config
------------
.. automodule:: sanic.config
:members:
:show-inheritance:

View File

@ -0,0 +1,17 @@
Blueprints
==========
sanic.blueprints
----------------
.. automodule:: sanic.blueprints
:members:
:show-inheritance:
:inherited-members:
sanic.blueprint_group
---------------------
.. automodule:: sanic.blueprint_group
:members:
:special-members:

47
docs/sanic/api/core.rst Normal file
View File

@ -0,0 +1,47 @@
Core
====
sanic.cookies
-------------
.. automodule:: sanic.cookies
:members:
:show-inheritance:
sanic.handlers
--------------
.. automodule:: sanic.handlers
:members:
:show-inheritance:
sanic.request
-------------
.. automodule:: sanic.request
:members:
:show-inheritance:
sanic.response
--------------
.. automodule:: sanic.response
:members:
:show-inheritance:
sanic.views
-----------
.. automodule:: sanic.views
:members:
:show-inheritance:
sanic.websocket
---------------
.. automodule:: sanic.websocket
:members:
:show-inheritance:

View File

@ -0,0 +1,16 @@
Exceptions
==========
sanic.errorpages
----------------
.. automodule:: sanic.errorpages
:members:
:show-inheritance:
sanic.exceptions
----------------
.. automodule:: sanic.exceptions
:members:
:show-inheritance:

18
docs/sanic/api/router.rst Normal file
View File

@ -0,0 +1,18 @@
Routing
=======
sanic_routing models
--------------------
.. autoclass:: sanic_routing.route::Route
:members:
.. autoclass:: sanic_routing.group::RouteGroup
:members:
sanic.router
------------
.. automodule:: sanic.router
:members:
:show-inheritance:

25
docs/sanic/api/server.rst Normal file
View File

@ -0,0 +1,25 @@
Sanic Server
============
sanic.http
----------
.. automodule:: sanic.http
:members:
:show-inheritance:
sanic.server
------------
.. automodule:: sanic.server
:members:
:show-inheritance:
sanic.worker
------------
.. automodule:: sanic.worker
:members:
:show-inheritance:

View File

@ -0,0 +1,16 @@
Utility
=======
sanic.compat
------------
.. automodule:: sanic.compat
:members:
:show-inheritance:
sanic.log
---------
.. automodule:: sanic.log
:members:
:show-inheritance:

View File

@ -1,132 +1,13 @@
📑 API Reference 📑 API Reference
================ ================
sanic.app .. toctree::
--------- :maxdepth: 2
.. automodule:: sanic.app api/app
:members: api/blueprints
:show-inheritance: api/core
:inherited-members: api/exceptions
api/router
sanic.blueprints api/server
---------------- api/utility
.. automodule:: sanic.blueprints
:members:
:show-inheritance:
:inherited-members:
sanic.blueprint_group
---------------------
.. automodule:: sanic.blueprint_group
:members:
:special-members:
sanic.compat
------------
.. automodule:: sanic.compat
:members:
:show-inheritance:
sanic.config
------------
.. automodule:: sanic.config
:members:
:show-inheritance:
sanic.cookies
-------------
.. automodule:: sanic.cookies
:members:
:show-inheritance:
sanic.errorpages
----------------
.. automodule:: sanic.errorpages
:members:
:show-inheritance:
sanic.exceptions
----------------
.. automodule:: sanic.exceptions
:members:
:show-inheritance:
sanic.handlers
--------------
.. automodule:: sanic.handlers
:members:
:show-inheritance:
sanic.http
----------
.. automodule:: sanic.http
:members:
:show-inheritance:
sanic.log
---------
.. automodule:: sanic.log
:members:
:show-inheritance:
sanic.request
-------------
.. automodule:: sanic.request
:members:
:show-inheritance:
sanic.response
--------------
.. automodule:: sanic.response
:members:
:show-inheritance:
sanic.router
------------
.. automodule:: sanic.router
:members:
:show-inheritance:
sanic.server
------------
.. automodule:: sanic.server
:members:
:show-inheritance:
sanic.views
-----------
.. automodule:: sanic.views
:members:
:show-inheritance:
sanic.websocket
---------------
.. automodule:: sanic.websocket
:members:
:show-inheritance:
sanic.worker
------------
.. automodule:: sanic.worker
:members:
:show-inheritance:

View File

@ -1,4 +1,4 @@
♥️ Contributing ♥️ Contributing
=============== ==============
.. include:: ../../CONTRIBUTING.rst .. include:: ../../CONTRIBUTING.rst

View File

@ -1,6 +1,7 @@
from sanic.__version__ import __version__ from sanic.__version__ import __version__
from sanic.app import Sanic from sanic.app import Sanic
from sanic.blueprints import Blueprint from sanic.blueprints import Blueprint
from sanic.constants import HTTPMethod
from sanic.request import Request from sanic.request import Request
from sanic.response import HTTPResponse, html, json, text from sanic.response import HTTPResponse, html, json, text
@ -9,6 +10,7 @@ __all__ = (
"__version__", "__version__",
"Sanic", "Sanic",
"Blueprint", "Blueprint",
"HTTPMethod",
"HTTPResponse", "HTTPResponse",
"Request", "Request",
"html", "html",

View File

@ -1 +1 @@
__version__ = "21.3.2" __version__ = "21.6.0"

View File

@ -279,8 +279,6 @@ class Blueprint(BaseSanic):
app._apply_signal(signal) app._apply_signal(signal)
self.routes = [route for route in routes if isinstance(route, Route)] self.routes = [route for route in routes if isinstance(route, Route)]
# Deprecate these in 21.6
self.websocket_routes = [ self.websocket_routes = [
route for route in self.routes if route.ctx.websocket route for route in self.routes if route.ctx.websocket
] ]

View File

@ -143,7 +143,7 @@ class StreamingHTTPResponse(BaseHTTPResponse):
.. warning:: .. warning::
**Deprecated** and set for removal in v21.6. You can now achieve the **Deprecated** and set for removal in v21.12. You can now achieve the
same functionality without a callback. same functionality without a callback.
.. code-block:: python .. code-block:: python
@ -174,12 +174,16 @@ class StreamingHTTPResponse(BaseHTTPResponse):
status: int = 200, status: int = 200,
headers: Optional[Union[Header, Dict[str, str]]] = None, headers: Optional[Union[Header, Dict[str, str]]] = None,
content_type: str = "text/plain; charset=utf-8", content_type: str = "text/plain; charset=utf-8",
chunked="deprecated", ignore_deprecation_notice: bool = False,
): ):
if chunked != "deprecated": if not ignore_deprecation_notice:
warn( warn(
"The chunked argument has been deprecated and will be " "Use of the StreamingHTTPResponse is deprecated in v21.6, and "
"removed in v21.6" "will be removed in v21.12. Please upgrade your streaming "
"response implementation. You can learn more here: "
"https://sanicframework.org/en/guide/advanced/streaming.html"
"#response-streaming. If you use the builtin stream() or "
"file_stream() methods, this upgrade will be be done for you."
) )
super().__init__() super().__init__()
@ -241,6 +245,12 @@ class HTTPResponse(BaseHTTPResponse):
async def eof(self): async def eof(self):
await self.send("", True) await self.send("", True)
async def __aenter__(self):
return self.send
async def __aexit__(self, *_):
await self.eof()
def empty( def empty(
status=204, headers: Optional[Dict[str, str]] = None status=204, headers: Optional[Dict[str, str]] = None
@ -402,7 +412,6 @@ async def file_stream(
mime_type: Optional[str] = None, mime_type: Optional[str] = None,
headers: Optional[Dict[str, str]] = None, headers: Optional[Dict[str, str]] = None,
filename: Optional[str] = None, filename: Optional[str] = None,
chunked="deprecated",
_range: Optional[Range] = None, _range: Optional[Range] = None,
) -> StreamingHTTPResponse: ) -> StreamingHTTPResponse:
"""Return a streaming response object with file data. """Return a streaming response object with file data.
@ -415,12 +424,6 @@ async def file_stream(
:param chunked: Deprecated :param chunked: Deprecated
:param _range: :param _range:
""" """
if chunked != "deprecated":
warn(
"The chunked argument has been deprecated and will be "
"removed in v21.6"
)
headers = headers or {} headers = headers or {}
if filename: if filename:
headers.setdefault( headers.setdefault(
@ -459,6 +462,7 @@ async def file_stream(
status=status, status=status,
headers=headers, headers=headers,
content_type=mime_type, content_type=mime_type,
ignore_deprecation_notice=True,
) )
@ -467,7 +471,6 @@ def stream(
status: int = 200, status: int = 200,
headers: Optional[Dict[str, str]] = None, headers: Optional[Dict[str, str]] = None,
content_type: str = "text/plain; charset=utf-8", content_type: str = "text/plain; charset=utf-8",
chunked="deprecated",
): ):
"""Accepts an coroutine `streaming_fn` which can be used to """Accepts an coroutine `streaming_fn` which can be used to
write chunks to a streaming response. Returns a `StreamingHTTPResponse`. write chunks to a streaming response. Returns a `StreamingHTTPResponse`.
@ -488,17 +491,12 @@ def stream(
:param headers: Custom Headers. :param headers: Custom Headers.
:param chunked: Deprecated :param chunked: Deprecated
""" """
if chunked != "deprecated":
warn(
"The chunked argument has been deprecated and will be "
"removed in v21.6"
)
return StreamingHTTPResponse( return StreamingHTTPResponse(
streaming_fn, streaming_fn,
headers=headers, headers=headers,
content_type=content_type, content_type=content_type,
status=status, status=status,
ignore_deprecation_notice=True,
) )

View File

@ -224,7 +224,6 @@ def non_chunked_streaming_app(app):
sample_streaming_fn, sample_streaming_fn,
headers={"Content-Length": "7"}, headers={"Content-Length": "7"},
content_type="text/csv", content_type="text/csv",
chunked=False,
) )
return app return app
@ -251,12 +250,8 @@ async def test_chunked_streaming_returns_correct_content_asgi(streaming_app):
def test_non_chunked_streaming_adds_correct_headers(non_chunked_streaming_app): def test_non_chunked_streaming_adds_correct_headers(non_chunked_streaming_app):
with pytest.warns(UserWarning) as record:
request, response = non_chunked_streaming_app.test_client.get("/") request, response = non_chunked_streaming_app.test_client.get("/")
assert len(record) == 1
assert "removed in v21.6" in record[0].message.args[0]
assert "Transfer-Encoding" not in response.headers assert "Transfer-Encoding" not in response.headers
assert response.headers["Content-Type"] == "text/csv" assert response.headers["Content-Type"] == "text/csv"
assert response.headers["Content-Length"] == "7" assert response.headers["Content-Length"] == "7"