Skip to content

Commit

Permalink
LTS v21.12 Deprecations (#2306)
Browse files Browse the repository at this point in the history
Co-authored-by: Néstor Pérez <25409753+prryplatypus@users.noreply.github.com>
  • Loading branch information
ahopkins and prryplatypus committed Dec 23, 2021
1 parent 98ce4bd commit 8c07e38
Show file tree
Hide file tree
Showing 72 changed files with 637 additions and 846 deletions.
192 changes: 65 additions & 127 deletions CHANGELOG.rst

Large diffs are not rendered by default.

7 changes: 0 additions & 7 deletions docs/sanic/api/core.rst
Expand Up @@ -38,10 +38,3 @@ sanic.views
.. automodule:: sanic.views
:members:
:show-inheritance:

sanic.websocket
---------------

.. automodule:: sanic.websocket
:members:
:show-inheritance:
4 changes: 2 additions & 2 deletions docs/sanic/changelog.rst
@@ -1,6 +1,6 @@
📜 Changelog
============

.. mdinclude:: ./releases/21.9.md

.. mdinclude:: ./releases/21/21.12.md
.. mdinclude:: ./releases/21/21.9.md
.. include:: ../../CHANGELOG.rst
58 changes: 58 additions & 0 deletions docs/sanic/releases/21/21.12.md
@@ -0,0 +1,58 @@
## Version 21.12.0

### Features
- [#2260](https://github.com/sanic-org/sanic/pull/2260) Allow early Blueprint registrations to still apply later added objects
- [#2262](https://github.com/sanic-org/sanic/pull/2262) Noisy exceptions - force logging of all exceptions
- [#2264](https://github.com/sanic-org/sanic/pull/2264) Optional `uvloop` by configuration
- [#2270](https://github.com/sanic-org/sanic/pull/2270) Vhost support using multiple TLS certificates
- [#2277](https://github.com/sanic-org/sanic/pull/2277) Change signal routing for increased consistency
- *BREAKING CHANGE*: If you were manually routing signals there is a breaking change. The signal router's `get` is no longer 100% determinative. There is now an additional step to loop thru the returned signals for proper matching on the requirements. If signals are being dispatched using `app.dispatch` or `bp.dispatch`, there is no change.
- [#2290](https://github.com/sanic-org/sanic/pull/2290) Add contextual exceptions
- [#2291](https://github.com/sanic-org/sanic/pull/2291) Increase join concat performance
- [#2295](https://github.com/sanic-org/sanic/pull/2295), [#2316](https://github.com/sanic-org/sanic/pull/2316), [#2331](https://github.com/sanic-org/sanic/pull/2331) Restructure of CLI and application state with new displays and more command parity with `app.run`
- [#2302](https://github.com/sanic-org/sanic/pull/2302) Add route context at definition time
- [#2304](https://github.com/sanic-org/sanic/pull/2304) Named tasks and new API for managing background tasks
- [#2307](https://github.com/sanic-org/sanic/pull/2307) On app auto-reload, provide insight of changed files
- [#2308](https://github.com/sanic-org/sanic/pull/2308) Auto extend application with [Sanic Extensions](https://sanicframework.org/en/plugins/sanic-ext/getting-started.html) if it is installed, and provide first class support for accessing the extensions
- [#2309](https://github.com/sanic-org/sanic/pull/2309) Builtin signals changed to `Enum`
- [#2313](https://github.com/sanic-org/sanic/pull/2313) Support additional config implementation use case
- [#2321](https://github.com/sanic-org/sanic/pull/2321) Refactor environment variable hydration logic
- [#2327](https://github.com/sanic-org/sanic/pull/2327) Prevent sending multiple or mixed responses on a single request
- [#2330](https://github.com/sanic-org/sanic/pull/2330) Custom type casting on environment variables
- [#2332](https://github.com/sanic-org/sanic/pull/2332) Make all deprecation notices consistent
- [#2335](https://github.com/sanic-org/sanic/pull/2335) Allow underscore to start instance names

### Bugfixes
- [#2273](https://github.com/sanic-org/sanic/pull/2273) Replace assignation by typing for `websocket_handshake`
- [#2285](https://github.com/sanic-org/sanic/pull/2285) Fix IPv6 display in startup logs
- [#2299](https://github.com/sanic-org/sanic/pull/2299) Dispatch `http.lifecyle.response` from exception handler

### Deprecations and Removals
- [#2306](https://github.com/sanic-org/sanic/pull/2306) Removal of deprecated items
- `Sanic` and `Blueprint` may no longer have arbitrary properties attached to them
- `Sanic` and `Blueprint` forced to have compliant names
- alphanumeric + `_` + `-`
- must start with letter or `_`
- `load_env` keyword argument of `Sanic`
- `sanic.exceptions.abort`
- `sanic.views.CompositionView`
- `sanic.response.StreamingHTTPResponse`
- *NOTE:* the `stream()` response method (where you pass a callable streaming function) has been deprecated and will be removed in v22.6. You should upgrade all streaming responses to the new style: https://sanicframework.org/en/guide/advanced/streaming.html#response-streaming
- [#2320](https://github.com/sanic-org/sanic/pull/2320) Remove app instance from Config for error handler setting

### Developer infrastructure
- [#2251](https://github.com/sanic-org/sanic/pull/2251) Change dev install command
- [#2286](https://github.com/sanic-org/sanic/pull/2286) Change codeclimate complexity threshold from 5 to 10
- [#2287](https://github.com/sanic-org/sanic/pull/2287) Update host test function names so they are not overwritten
- [#2292](https://github.com/sanic-org/sanic/pull/2292) Fail CI on error
- [#2311](https://github.com/sanic-org/sanic/pull/2311), [#2324](https://github.com/sanic-org/sanic/pull/2324) Do not run tests for draft PRs
- [#2336](https://github.com/sanic-org/sanic/pull/2336) Remove paths from coverage checks
- [#2338](https://github.com/sanic-org/sanic/pull/2338) Cleanup ports on tests

### Improved Documentation
- [#2269](https://github.com/sanic-org/sanic/pull/2269), [#2329](https://github.com/sanic-org/sanic/pull/2329), [#2333](https://github.com/sanic-org/sanic/pull/2333) Cleanup typos and fix language

### Miscellaneous
- [#2257](https://github.com/sanic-org/sanic/pull/2257), [#2294](https://github.com/sanic-org/sanic/pull/2294), [#2341](https://github.com/sanic-org/sanic/pull/2341) Add Python 3.10 support
- [#2279](https://github.com/sanic-org/sanic/pull/2279), [#2317](https://github.com/sanic-org/sanic/pull/2317), [#2322](https://github.com/sanic-org/sanic/pull/2322) Add/correct missing type annotations
- [#2305](https://github.com/sanic-org/sanic/pull/2305) Fix examples to use modern implementations
12 changes: 11 additions & 1 deletion docs/sanic/releases/21.9.md → docs/sanic/releases/21/21.9.md
@@ -1,4 +1,14 @@
## Version 21.9
## Version 21.9.3
*Rerelease of v21.9.2 with some cleanup*

## Version 21.9.2
- [#2268](https://github.com/sanic-org/sanic/pull/2268) Make HTTP connections start in IDLE stage, avoiding delays and error messages
- [#2310](https://github.com/sanic-org/sanic/pull/2310) More consistent config setting with post-FALLBACK_ERROR_FORMAT apply

## Version 21.9.1
- [#2259](https://github.com/sanic-org/sanic/pull/2259) Allow non-conforming ErrorHandlers

## Version 21.9.0

### Features
- [#2158](https://github.com/sanic-org/sanic/pull/2158), [#2248](https://github.com/sanic-org/sanic/pull/2248) Complete overhaul of I/O to websockets
Expand Down
2 changes: 1 addition & 1 deletion examples/add_task_sanic.py
Expand Up @@ -5,7 +5,7 @@
from sanic import Sanic


app = Sanic(__name__)
app = Sanic("Example")


async def notify_server_started_after_five_seconds():
Expand Down
2 changes: 1 addition & 1 deletion examples/amending_request_object.py
Expand Up @@ -4,7 +4,7 @@
from sanic.response import text


app = Sanic(__name__)
app = Sanic("Example")


@app.middleware("request")
Expand Down
2 changes: 1 addition & 1 deletion examples/authorized_sanic.py
Expand Up @@ -6,7 +6,7 @@
from sanic.response import json


app = Sanic(__name__)
app = Sanic("Example")


def check_request_for_authorization_status(request):
Expand Down
4 changes: 2 additions & 2 deletions examples/blueprint_middlware_execution_order.py
Expand Up @@ -8,9 +8,9 @@
On a valid request, it should print "1 2 3 6 5 4" to terminal
"""

app = Sanic(__name__)
app = Sanic("Example")

bp = Blueprint("bp_" + __name__)
bp = Blueprint("bp_example")


@bp.on_request
Expand Down
8 changes: 4 additions & 4 deletions examples/blueprints.py
Expand Up @@ -2,10 +2,10 @@
from sanic.response import file, json


app = Sanic(__name__)
blueprint = Blueprint("name", url_prefix="/my_blueprint")
blueprint2 = Blueprint("name2", url_prefix="/my_blueprint2")
blueprint3 = Blueprint("name3", url_prefix="/my_blueprint3")
app = Sanic("Example")
blueprint = Blueprint("bp_example", url_prefix="/my_blueprint")
blueprint2 = Blueprint("bp_example2", url_prefix="/my_blueprint2")
blueprint3 = Blueprint("bp_example3", url_prefix="/my_blueprint3")


@blueprint.route("/foo")
Expand Down
2 changes: 1 addition & 1 deletion examples/delayed_response.py
Expand Up @@ -3,7 +3,7 @@
from sanic import Sanic, response


app = Sanic(__name__, strict_slashes=True)
app = Sanic("DelayedResponseApp", strict_slashes=True)


@app.get("/")
Expand Down
2 changes: 1 addition & 1 deletion examples/exception_monitoring.py
Expand Up @@ -41,7 +41,7 @@ def default(self, request, exception):


handler = CustomHandler()
app = Sanic(__name__, error_handler=handler)
app = Sanic("Example", error_handler=handler)


@app.route("/")
Expand Down
8 changes: 4 additions & 4 deletions examples/hello_world.py
@@ -1,13 +1,13 @@
from sanic import Sanic
from sanic import response
from sanic import Sanic, response

app = Sanic(__name__)

app = Sanic("Example")


@app.route("/")
async def test(request):
return response.json({"test": True})


if __name__ == '__main__':
if __name__ == "__main__":
app.run(host="0.0.0.0", port=8000)
2 changes: 1 addition & 1 deletion examples/limit_concurrency.py
Expand Up @@ -6,7 +6,7 @@
from sanic.response import json


app = Sanic(__name__)
app = Sanic("Example")

sem = None

Expand Down
2 changes: 1 addition & 1 deletion examples/log_request_id.py
Expand Up @@ -44,7 +44,7 @@ def filter(self, record):
}


app = Sanic(__name__, log_config=LOG_SETTINGS)
app = Sanic("Example", log_config=LOG_SETTINGS)


@app.on_request
Expand Down
2 changes: 1 addition & 1 deletion examples/logdna_example.py
Expand Up @@ -43,7 +43,7 @@ def get_mac_address():
logdna.setLevel(logging.INFO)
logdna.addHandler(logdna_handler)

app = Sanic(__name__)
app = Sanic("Example")


@app.middleware
Expand Down
26 changes: 14 additions & 12 deletions examples/modify_header_example.py
Expand Up @@ -2,27 +2,29 @@
Modify header or status in response
"""

from sanic import Sanic
from sanic import response
from sanic import Sanic, response

app = Sanic(__name__)

app = Sanic("Example")

@app.route('/')

@app.route("/")
def handle_request(request):
return response.json(
{'message': 'Hello world!'},
headers={'X-Served-By': 'sanic'},
status=200
{"message": "Hello world!"},
headers={"X-Served-By": "sanic"},
status=200,
)


@app.route('/unauthorized')
@app.route("/unauthorized")
def handle_request(request):
return response.json(
{'message': 'You are not authorized'},
headers={'X-Served-By': 'sanic'},
status=404
{"message": "You are not authorized"},
headers={"X-Served-By": "sanic"},
status=404,
)

app.run(host="0.0.0.0", port=8000, debug=True)

if __name__ == "__main__":
app.run(host="0.0.0.0", port=8000, debug=True)
2 changes: 1 addition & 1 deletion examples/pytest_xdist.py
Expand Up @@ -32,7 +32,7 @@ def test_port(worker_id):

@pytest.fixture(scope="session")
def app():
app = Sanic()
app = Sanic("Example")

@app.route("/")
async def index(request):
Expand Down
12 changes: 4 additions & 8 deletions examples/raygun_example.py
Expand Up @@ -8,7 +8,6 @@


class RaygunExceptionReporter(ErrorHandler):

def __init__(self, raygun_api_key=None):
super().__init__()
if raygun_api_key is None:
Expand All @@ -22,16 +21,13 @@ def default(self, request, exception):


raygun_error_reporter = RaygunExceptionReporter()
app = Sanic(__name__, error_handler=raygun_error_reporter)
app = Sanic("Example", error_handler=raygun_error_reporter)


@app.route("/raise")
async def test(request):
raise SanicException('You Broke It!')
raise SanicException("You Broke It!")


if __name__ == '__main__':
app.run(
host="0.0.0.0",
port=getenv("PORT", 8080)
)
if __name__ == "__main__":
app.run(host="0.0.0.0", port=getenv("PORT", 8080))
18 changes: 9 additions & 9 deletions examples/redirect_example.py
@@ -1,18 +1,18 @@
from sanic import Sanic
from sanic import response
from sanic import Sanic, response

app = Sanic(__name__)


@app.route('/')
app = Sanic("Example")


@app.route("/")
def handle_request(request):
return response.redirect('/redirect')
return response.redirect("/redirect")


@app.route('/redirect')
@app.route("/redirect")
async def test(request):
return response.json({"Redirected": True})


if __name__ == '__main__':
app.run(host="0.0.0.0", port=8000)
if __name__ == "__main__":
app.run(host="0.0.0.0", port=8000)

0 comments on commit 8c07e38

Please sign in to comment.