Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 3.11-dev support #847

Merged
merged 8 commits into from
Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.8, 3.9, "3.10"]
python-version: [3.8, 3.9, "3.10", 3.11-dev]

runs-on: ${{ matrix.os }}

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Gateway.
Built on good intentions and the hope that it will be extendable and reusable, rather than an obstacle for future
development.

Python 3.8, 3.9 and 3.10 are currently supported.
Python 3.8, 3.9 and 3.10 and 3.11-dev are currently supported.

## Installation

Expand Down Expand Up @@ -168,7 +168,7 @@ other internal settings in the interpreter.
### `hikari[speedups]`

If you have a C compiler (Microsoft VC++ Redistributable 14.0 or newer, or a modern copy of GCC/G++, Clang, etc), you
can install Hikari using `pip install -U hikari[speedups]`. This will install `aiodns`, `cchardet`, `Brotli`, and
can install Hikari using `pip install -U hikari[speedups]`. This will install `aiohttp` with its available speedups, and
`ciso8601` which will provide you with a small performance boost.

### `uvloop`
Expand Down
1 change: 1 addition & 0 deletions changes/847.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add python 3.11-dev support.
12 changes: 6 additions & 6 deletions hikari/impl/interaction_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,12 +341,12 @@ async def aiohttp_hook(self, request: aiohttp.web.Request) -> aiohttp.web.Respon

return aiohttp.web.Response(status=response.status_code, headers=response.headers, body=multipart)

headers = response.headers
if response.content_type:
headers = headers or {}
headers[_CONTENT_TYPE_KEY] = response.content_type

return aiohttp.web.Response(status=response.status_code, headers=headers, body=response.payload)
return aiohttp.web.Response(
status=response.status_code,
headers=response.headers,
body=response.payload,
content_type=response.content_type,
)

async def close(self) -> None:
"""Gracefully close the server and any open connections."""
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def parse_requirements_file(path):
maintainer_email=metadata.email,
license=metadata.license,
url=metadata.url,
python_requires=">=3.8.0,<3.11",
python_requires=">=3.8.0,<3.12",
packages=setuptools.find_namespace_packages(include=["hikari*"]),
entry_points={"console_scripts": ["hikari = hikari.cli:main"]},
install_requires=parse_requirements_file("requirements.txt"),
Expand Down Expand Up @@ -94,6 +94,7 @@ def parse_requirements_file(path):
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: Implementation :: CPython",
"Topic :: Communications :: Chat",
"Topic :: Internet :: WWW/HTTP",
Expand Down
4 changes: 1 addition & 3 deletions speedup-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
aiodns~=3.0
cchardet~=2.1
Brotli~=1.0
aiohttp[speedups]~=3.8
ciso8601~=2.2
16 changes: 8 additions & 8 deletions tests/hikari/impl/test_interaction_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ async def test__fetch_public_key_when_public_key_already_set(
async def test_aiohttp_hook(self, mock_interaction_server: interaction_server_impl.InteractionServer):
mock_interaction_server.on_interaction = mock.AsyncMock(
return_value=mock.Mock(
payload=b"abody", files=[], status_code=200, headers={"header1": "ok"}, content_type="oogabooga"
payload=b"abody", files=[], status_code=200, headers={"header1": "ok"}, content_type="ooga/booga"
)
)
request = mock.Mock(
Expand All @@ -342,16 +342,16 @@ async def test_aiohttp_hook(self, mock_interaction_server: interaction_server_im
body=b"bfddasdasd", signature=b"troekpewieojksi9", timestamp=b"123123"
)
assert result.body == b"abody"
assert result.content_type == "oogabooga"
assert result.headers == {"header1": "ok", "Content-Type": "oogabooga"}
assert result.content_type == "ooga/booga"
assert result.headers == {"header1": "ok", "Content-Type": "ooga/booga"}
assert result.status == 200

@pytest.mark.asyncio()
async def test_aiohttp_hook_when_no_other_headers(
self, mock_interaction_server: interaction_server_impl.InteractionServer
):
mock_interaction_server.on_interaction = mock.AsyncMock(
return_value=mock.Mock(payload=b"abody", files=[], headers=None, status_code=200, content_type="oogabooga")
return_value=mock.Mock(payload=b"abody", files=[], headers=None, status_code=200, content_type="ooga/booga")
)
request = mock.Mock(
aiohttp.web.Request,
Expand All @@ -366,8 +366,8 @@ async def test_aiohttp_hook_when_no_other_headers(
body=b"bfddasdasd", signature=b"troekpewieojksi9", timestamp=b"123123"
)
assert result.body == b"abody"
assert result.content_type == "oogabooga"
assert result.headers == {"Content-Type": "oogabooga"}
assert result.content_type == "ooga/booga"
assert result.headers == {"Content-Type": "ooga/booga"}
assert result.status == 200

@pytest.mark.asyncio()
Expand All @@ -378,7 +378,7 @@ async def test_aiohttp_hook_when_files(self, mock_interaction_server: interactio
files=[files.Bytes("x" * 329, "meow.txt"), files.Bytes("y" * 124, "nyaa.txt")],
status_code=200,
headers={"header1": "ok"},
content_type="oogabooga",
content_type="ooga/booga",
)
)
request = mock.Mock(
Expand Down Expand Up @@ -406,7 +406,7 @@ async def test_aiohttp_hook_when_files(self, mock_interaction_server: interactio

boundary = result.body.boundary.encode()
assert mock_writer.payload == (
b"--" + boundary + b"""\r\nContent-Type: oogabooga\r\nContent-Disposition: form-data; name="payload_json"""
b"--" + boundary + b"""\r\nContent-Type: ooga/booga\r\nContent-Disposition: form-data; name="payload_json"""
b""""\r\nContent-Length: 5\r\n\r\nabody\r\n--""" + boundary + b"""\r\nContent-Type: text/plain\r\nConten"""
b"""t-Disposition: form-data; name="files[0]"; filename="meow.txt"\r\n\r\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"""
b"""xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"""
Expand Down