Skip to content

Commit

Permalink
Merge branch 'master' into add_type_hints_2183
Browse files Browse the repository at this point in the history
  • Loading branch information
CaselIT committed Aug 21, 2024
2 parents e995828 + edcd5f6 commit 51e742a
Show file tree
Hide file tree
Showing 53 changed files with 381 additions and 521 deletions.
14 changes: 14 additions & 0 deletions docs/changes/4.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@ Changes to Supported Platforms
later 4.x release, especially if we are faced with incompatible ecosystem
changes in typing, Cython, etc.

Typing support
--------------

Type checking support was introduced in version 4.0. While most of the library is
now typed, further type annotations may be added throughout the 4.x release cycle.
To improve them, we may introduce changes to the typing that do not affect
runtime behavior, but may surface new or different errors with type checkers.

.. note::

All type aliases in falcon are considered private, and if used should be
imported inside ``if TYPE_CHECKING:`` blocks to avoid possible import errors
after an update.

.. towncrier release notes start
Contributors to this Release
Expand Down
1 change: 0 additions & 1 deletion requirements/cibwtest
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
msgpack
pytest
pytest-asyncio<0.22.0
pyyaml
requests
1 change: 0 additions & 1 deletion requirements/mintest
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
coverage>=4.1
pytest
pytest-asyncio<0.22.0
requests
2 changes: 0 additions & 2 deletions requirements/tests
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ requests
testtools; python_version < '3.10'

# ASGI Specific (daphne is installed on a its own tox env)
# TODO(vytas): Some ASGI tests hang with pytest-asyncio-0.23 on 3.8 & 3.9.
pytest-asyncio < 0.22.0
aiofiles
httpx
uvicorn >= 0.17.0
Expand Down
79 changes: 0 additions & 79 deletions tests/_util.py

This file was deleted.

4 changes: 0 additions & 4 deletions tests/asgi/test_asgi_conductor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from falcon.asgi import App


@pytest.mark.asyncio
async def test_default_headers():
class Resource:
async def on_get(self, req, resp):
Expand All @@ -21,7 +20,6 @@ async def on_get(self, req, resp):


@pytest.mark.parametrize('simulate_method', ['request', 'simulate_request'])
@pytest.mark.asyncio
async def test_generic_request(simulate_method):
class Resource:
async def on_lock(self, req, resp):
Expand All @@ -37,7 +35,6 @@ async def on_lock(self, req, resp):
assert result.status_code == 422


@pytest.mark.asyncio
async def test_wsgi_not_supported():
with pytest.raises(falcon.CompatibilityError):
async with testing.TestClient(falcon.App()):
Expand All @@ -52,7 +49,6 @@ async def test_wsgi_not_supported():
'method', ['get', 'head', 'post', 'put', 'options', 'patch', 'delete']
)
@pytest.mark.parametrize('use_alias', ['alias', 'simulate'])
@pytest.mark.asyncio
async def test_responders(method, use_alias):
class Resource:
async def on_get(self, req, resp):
Expand Down
2 changes: 0 additions & 2 deletions tests/asgi/test_asgi_helpers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import inspect

import falcon
from falcon.asgi import _asgi_helpers


Expand All @@ -15,7 +14,6 @@ async def _call_factory(self, scope, receive, send):
__call__ = _asgi_helpers._wrap_asgi_coroutine_func(unorthodox_call)


@falcon.runs_sync
async def test_intricate_app():
async def receive():
pass
Expand Down
14 changes: 0 additions & 14 deletions tests/asgi/test_asgi_servers.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ def test_sse_client_disconnects_early(self, server_base_url):
timeout=(_asgi_test_app.SSE_TEST_MAX_DELAY_SEC / 2),
)

@pytest.mark.asyncio
@pytest.mark.skipif(httpx is None, reason='httpx is required for this test')
async def test_stream_chunked_request(self, server_base_url):
"""Regression test for https://github.com/falconry/falcon/issues/2024"""
Expand All @@ -197,7 +196,6 @@ async def emitter():
websockets is None, reason='websockets is required for this test class'
)
class TestWebSocket:
@pytest.mark.asyncio
@pytest.mark.parametrize('explicit_close', [True, False])
@pytest.mark.parametrize('close_code', [None, 4321])
async def test_hello(self, explicit_close, close_code, server_url_events_ws):
Expand Down Expand Up @@ -242,7 +240,6 @@ async def test_hello(self, explicit_close, close_code, server_url_events_ws):

assert got_message

@pytest.mark.asyncio
@pytest.mark.parametrize('explicit_close', [True, False])
@pytest.mark.parametrize('close_code', [None, 4040])
async def test_rejected(self, explicit_close, close_code, server_url_events_ws):
Expand All @@ -261,7 +258,6 @@ async def test_rejected(self, explicit_close, close_code, server_url_events_ws):

assert exc_info.value.status_code == 403

@pytest.mark.asyncio
async def test_missing_responder(self, server_url_events_ws):
server_url_events_ws += '/404'

Expand All @@ -271,7 +267,6 @@ async def test_missing_responder(self, server_url_events_ws):

assert exc_info.value.status_code == 403

@pytest.mark.asyncio
@pytest.mark.parametrize(
'subprotocol, expected',
[
Expand All @@ -290,7 +285,6 @@ async def test_select_subprotocol_known(
) as ws:
assert ws.subprotocol == expected

@pytest.mark.asyncio
async def test_select_subprotocol_unknown(self, server_url_events_ws):
extra_headers = {'X-Subprotocol': 'xmpp'}

Expand Down Expand Up @@ -322,7 +316,6 @@ async def test_select_subprotocol_unknown(self, server_url_events_ws):
# tried to capture this output and check it in the test below,
# but the usual ways of capturing stdout/stderr with pytest do
# not work.
@pytest.mark.asyncio
async def test_disconnecting_client_early(self, server_url_events_ws):
ws = await websockets.connect(
server_url_events_ws, extra_headers={'X-Close': 'True'}
Expand All @@ -342,7 +335,6 @@ async def test_disconnecting_client_early(self, server_url_events_ws):
# messages after the close.
await asyncio.sleep(1)

@pytest.mark.asyncio
async def test_send_before_accept(self, server_url_events_ws):
extra_headers = {'x-accept': 'skip'}

Expand All @@ -352,7 +344,6 @@ async def test_send_before_accept(self, server_url_events_ws):
message = await ws.recv()
assert message == 'OperationNotAllowed'

@pytest.mark.asyncio
async def test_recv_before_accept(self, server_url_events_ws):
extra_headers = {'x-accept': 'skip', 'x-command': 'recv'}

Expand All @@ -362,7 +353,6 @@ async def test_recv_before_accept(self, server_url_events_ws):
message = await ws.recv()
assert message == 'OperationNotAllowed'

@pytest.mark.asyncio
async def test_invalid_close_code(self, server_url_events_ws):
extra_headers = {'x-close': 'True', 'x-close-code': 42}

Expand All @@ -379,7 +369,6 @@ async def test_invalid_close_code(self, server_url_events_ws):
elapsed = time.time() - start
assert elapsed < 2

@pytest.mark.asyncio
async def test_close_code_on_unhandled_error(self, server_url_events_ws):
extra_headers = {'x-raise-error': 'generic'}

Expand All @@ -390,7 +379,6 @@ async def test_close_code_on_unhandled_error(self, server_url_events_ws):

assert ws.close_code in {3011, 1011}

@pytest.mark.asyncio
async def test_close_code_on_unhandled_http_error(self, server_url_events_ws):
extra_headers = {'x-raise-error': 'http'}

Expand All @@ -401,7 +389,6 @@ async def test_close_code_on_unhandled_http_error(self, server_url_events_ws):

assert ws.close_code == 3400

@pytest.mark.asyncio
@pytest.mark.parametrize('mismatch', ['send', 'recv'])
@pytest.mark.parametrize('mismatch_type', ['text', 'data'])
async def test_type_mismatch(self, mismatch, mismatch_type, server_url_events_ws):
Expand All @@ -423,7 +410,6 @@ async def test_type_mismatch(self, mismatch, mismatch_type, server_url_events_ws

assert ws.close_code in {3011, 1011}

@pytest.mark.asyncio
async def test_passing_path_params(self, server_base_url_ws):
expected_feed_id = '1ee7'
url = f'{server_base_url_ws}feeds/{expected_feed_id}'
Expand Down
2 changes: 0 additions & 2 deletions tests/asgi/test_boundedstream_asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ async def test_iteration():
falcon.async_to_sync(test_iteration)


@falcon.runs_sync
async def test_iterate_streaming_request():
events = iter(
(
Expand Down Expand Up @@ -274,7 +273,6 @@ async def t():
falcon.async_to_sync(t)


@falcon.runs_sync
async def test_exhaust():
emitter = testing.ASGIRequestEventEmitter(b'123456798' * 1024)
stream = asgi.BoundedStream(emitter)
Expand Down
Loading

0 comments on commit 51e742a

Please sign in to comment.