Addressed typing warnings from pyright

This commit is contained in:
Miguel Grinberg
2025-04-06 23:11:30 +01:00
parent e7ee74d6bb
commit b6f232db11
3 changed files with 6 additions and 6 deletions

View File

@@ -19,7 +19,7 @@ class TestResponse:
#: explicitly sets it on the response object. #: explicitly sets it on the response object.
self.reason = None self.reason = None
#: A dictionary with the response headers. #: A dictionary with the response headers.
self.headers = None self.headers = {}
#: The body of the response, as a bytes object. #: The body of the response, as a bytes object.
self.body = None self.body = None
#: The body of the response, decoded to a UTF-8 string. Set to #: The body of the response, decoded to a UTF-8 string. Set to
@@ -195,7 +195,7 @@ class TestClient:
('127.0.0.1', 1234)) ('127.0.0.1', 1234))
res = await self.app.dispatch_request(req) res = await self.app.dispatch_request(req)
if res == Response.already_handled: if res == Response.already_handled:
return None return TestResponse()
res.complete() res.complete()
self._update_cookies(res) self._update_cookies(res)

View File

@@ -771,7 +771,7 @@ class TestMicrodot(unittest.TestCase):
client = TestClient(app) client = TestClient(app)
res = self._run(client.get('/')) res = self._run(client.get('/'))
self.assertEqual(res, None) self.assertEqual(res.body, None)
def test_mount(self): def test_mount(self):
subapp = Microdot() subapp = Microdot()

View File

@@ -46,11 +46,11 @@ class TestWebSocket(unittest.TestCase):
client = TestClient(app) client = TestClient(app)
res = self._run(client.websocket('/echo', ws)) res = self._run(client.websocket('/echo', ws))
self.assertIsNone(res) self.assertIsNone(res.body)
self.assertEqual(results, ['hello', b'bye', b'*' * 300, b'+' * 65537]) self.assertEqual(results, ['hello', b'bye', b'*' * 300, b'+' * 65537])
res = self._run(client.websocket('/divzero', ws)) res = self._run(client.websocket('/divzero', ws))
self.assertIsNone(res) self.assertIsNone(res.body)
WebSocket.max_message_length = -1 WebSocket.max_message_length = -1
@unittest.skipIf(sys.implementation.name == 'micropython', @unittest.skipIf(sys.implementation.name == 'micropython',
@@ -74,7 +74,7 @@ class TestWebSocket(unittest.TestCase):
client = TestClient(app) client = TestClient(app)
res = self._run(client.websocket('/echo', ws)) res = self._run(client.websocket('/echo', ws))
self.assertIsNone(res) self.assertIsNone(res.body)
self.assertEqual(results, []) self.assertEqual(results, [])
Request.max_body_length = saved_max_body_length Request.max_body_length = saved_max_body_length