Skip to content

Commit

Permalink
Merge branch 'master' into feat/stage-instances
Browse files Browse the repository at this point in the history
  • Loading branch information
null-domain authored Dec 20, 2023
2 parents 144f93d + eac9567 commit 257e387
Show file tree
Hide file tree
Showing 37 changed files with 238 additions and 117 deletions.
43 changes: 29 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.8, 3.9, "3.10", 3.11]
python-version: [3.8, 3.9, "3.10", 3.11, 3.12]

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

Expand All @@ -26,7 +26,7 @@ jobs:
uses: actions/checkout@v4

- name: Setup python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

Expand All @@ -49,17 +49,15 @@ jobs:
nox -s pytest-all-features -- --cov-append
python scripts/ci/normalize_coverage.py
mv .coverage .coverage.${{ matrix.os }}.${{ matrix.python-version }}
- name: Upload coverage
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage
path: .coverage.${{ matrix.os }}.${{ matrix.python-version }}
name: .coverage.${{ matrix.os }}.${{ matrix.python-version }}
path: .coverage
retention-days: 1
if-no-files-found: error


upload-coverage:
needs: [test]
runs-on: ubuntu-latest
Expand All @@ -69,14 +67,31 @@ jobs:
uses: actions/checkout@v4

- name: Setup python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Download coverage
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: coverage
path: coverages/
# Not specifying any name will lead to the download of all available artifacts

# Since artifacts v2, we can no longer upload multiple artifacts
# with the same name and have them re-download as if it were a directory.
# For this reason, we need to download all available artifacts, filter
# out for only coverage files and then place them in the root directory
# with the name of the artifact
- name: Extract individual coverage files
run: |
cd coverages
for coverage_dir in ./.coverage.*; do
mv "$coverage_dir/.coverage" "../$coverage_dir"
rmdir "$coverage_dir"
done
cd ..
- name: Combine coverage
run: |
Expand All @@ -100,7 +115,7 @@ jobs:
uses: actions/checkout@v4

- name: Setup python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.8

Expand Down Expand Up @@ -157,7 +172,7 @@ jobs:
uses: actions/checkout@v4

- name: Setup python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.8

Expand All @@ -174,7 +189,7 @@ jobs:
uses: actions/checkout@v4

- name: Setup python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.9

Expand All @@ -188,7 +203,7 @@ jobs:
- name: Upload artifacts
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: docs
path: public/docs
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ jobs:
uses: actions/checkout@v4

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: python

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
2 changes: 1 addition & 1 deletion .github/workflows/fragments-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
fetch-depth: 0

- name: Setup python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.8

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
git config --global user.email "90276125+hikari-bot[bot]@users.noreply.github.com"
- name: Setup python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.8

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ jobs:
git config --global user.email "90276125+hikari-bot[bot]@users.noreply.github.com"
- name: Setup python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.8

- name: Temporarily disable "include administrators" branch protection
uses: benjefferies/branch-protection-bot@1.0.9
uses: benjefferies/branch-protection-bot@v1.1.2
with:
access_token: ${{ steps.generate_token.outputs.token }}
enforce_admins: false
Expand All @@ -46,7 +46,7 @@ jobs:
run: bash scripts/ci/release.sh

- name: Re-enable "include administrators" branch protection
uses: benjefferies/branch-protection-bot@1.0.9
uses: benjefferies/branch-protection-bot@v1.1.2
if: always()
with:
access_token: ${{ steps.generate_token.outputs.token }}
Expand Down
File renamed without changes.
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
## 2.0.0.dev122 (2023-11-18)

### Deprecation

- Deprecate `Permissions.MANAGE_EMOJIS_AND_STICKERS` in favour of `Permissions.MANAGE_GUILD_EXPREASSIONS` ([#1758](https://github.com/hikari-py/hikari/issues/1758))

### Features

- Add Python 3.12 support. ([#1357](https://github.com/hikari-py/hikari/issues/1357))
- Allow class listeners ([#1661](https://github.com/hikari-py/hikari/issues/1661))
- Add missing `clear_x` methods to `InteractionMessageBuilder`
- This brings the functionality more in-line with other message edit APIs ([#1740](https://github.com/hikari-py/hikari/issues/1740))
- Add missing permissions ([#1758](https://github.com/hikari-py/hikari/issues/1758))

### Bugfixes

- Fix optional connection "revoked" field KeyError when fetching connections. ([#1720](https://github.com/hikari-py/hikari/issues/1720))
- Ensure shard connect and disconnect always get sent in pairs and properly waited for ([#1744](https://github.com/hikari-py/hikari/issues/1744))
- Improve handing of force exiting a bot (double interrupt)
- Improve exception message
- Reset signal handlers to original ones after no longer capturing signals ([#1745](https://github.com/hikari-py/hikari/issues/1745))

---
## 2.0.0.dev121 (2023-09-10)

### Features
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Gateway APIs.
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, 3.10 and 3.11 are currently supported.
Python 3.8, 3.9, 3.10, 3.11 and 3.12 are currently supported.

## Installation

Expand Down Expand Up @@ -286,11 +286,12 @@ This replaces the default `asyncio` event loop with one that uses `libuv` intern
and then amend your script to be something similar to the following example to utilise it in your application:

```py
import asyncio
import os

if os.name != "nt":
import uvloop
uvloop.install()
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())


# Your code goes here
Expand Down
4 changes: 4 additions & 0 deletions changes/.template.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,7 @@ No significant changes.
{% endif %}
{% endfor %}
---
{#
This comment adds one more newline at the end of the rendered newsfile content.
In this way the there are 2 newlines between the latest release and the previous release content.
#}
1 change: 0 additions & 1 deletion changes/1661.feature.md

This file was deleted.

1 change: 0 additions & 1 deletion changes/1720.bugfix.md

This file was deleted.

2 changes: 0 additions & 2 deletions changes/1740.feature.md

This file was deleted.

1 change: 0 additions & 1 deletion changes/1744.bugfix.md

This file was deleted.

3 changes: 0 additions & 3 deletions changes/1745.bugfix.md

This file was deleted.

1 change: 1 addition & 0 deletions changes/1762.breaking.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove previously deprecated `Permissions.MANAGE_EMOJIS_AND_STICKERS`
2 changes: 1 addition & 1 deletion dev-requirements/build.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
setuptools>=65.2.0
wheel==0.41.3
wheel==0.42.0
2 changes: 1 addition & 1 deletion dev-requirements/coverage.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
coverage[toml]==7.3.2
coverage[toml]==7.3.3
4 changes: 2 additions & 2 deletions dev-requirements/formatting.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
black==23.11.0
isort==5.12.0
black==23.12.0
isort==5.13.2
2 changes: 1 addition & 1 deletion dev-requirements/mypy.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
mypy==1.6.1
mypy==1.7.1
2 changes: 1 addition & 1 deletion dev-requirements/pyright.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pyright==1.1.336
pyright==1.1.342
2 changes: 1 addition & 1 deletion dev-requirements/pytest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
mock==5.1.0

pytest==7.4.3
pytest-asyncio==0.21.1
pytest-asyncio==0.23.2
pytest-cov==4.1.0
pytest-randomly==3.15.0

Expand Down
2 changes: 1 addition & 1 deletion dev-requirements/sphinx.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ numpydoc==1.6.0
myst-parser==2.0.0

# Misc extensions
sphinxext.opengraph==0.9.0
sphinxext.opengraph==0.9.1
sphinx-copybutton==0.5.2
sphinxcontrib-towncrier==0.4.0a0
2 changes: 1 addition & 1 deletion hikari/_about.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@
__issue_tracker__: typing.Final[str] = "https://github.com/hikari-py/hikari/issues"
__license__: typing.Final[str] = "MIT"
__url__: typing.Final[str] = "https://github.com/hikari-py/hikari"
__version__: typing.Final[str] = "2.0.0.dev122"
__version__: typing.Final[str] = "2.0.0.dev123"
__git_sha1__: typing.Final[str] = "HEAD"
5 changes: 4 additions & 1 deletion hikari/impl/event_manager_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,10 @@ def dispatch(self, event: base_events.Event) -> asyncio.Future[typing.Any]:
del self._waiters[cls]
self._increment_waiter_group_count(cls, -1)

return asyncio.gather(*tasks) if tasks else aio.completed_future()
if tasks:
return asyncio.gather(*tasks)

return aio.completed_future()

def stream(
self,
Expand Down
3 changes: 2 additions & 1 deletion hikari/impl/shard.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@ def _handle_other_message(self, message: aiohttp.WSMessage, /) -> typing.NoRetur
close_code = int(message.data)

can_reconnect = close_code < 4000 or close_code in _RECONNECTABLE_CLOSE_CODES
raise errors.GatewayServerClosedConnectionError(message.extra, close_code, can_reconnect)
# str(message.extra) is used to cast the possible None to a string
raise errors.GatewayServerClosedConnectionError(str(message.extra), close_code, can_reconnect)

if message.type == aiohttp.WSMsgType.CLOSING or message.type == aiohttp.WSMsgType.CLOSED:
# May be caused by the server shutting us down.
Expand Down
2 changes: 1 addition & 1 deletion hikari/internal/aio.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ async def all_of(*aws: typing.Awaitable[T_co], timeout: typing.Optional[float] =
typing.Sequence[T_co]
The results of each awaitable in the order they were invoked in.
"""
fs = tuple(map(asyncio.ensure_future, aws))
fs: typing.Tuple[asyncio.Future[T_co], ...] = tuple(map(asyncio.ensure_future, aws))
gatherer = asyncio.gather(*fs)

try:
Expand Down
5 changes: 1 addition & 4 deletions hikari/internal/attrs_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,7 @@ def get_fields_definition(
init_results: typing.List[typing.Tuple[attrs.Attribute[typing.Any], str]] = []
non_init_results: typing.List[attrs.Attribute[typing.Any]] = []

# Mypy has a bug where it will always report
# "Argument 1 to "fields" has incompatible type "Type[AttrsInstance]"; expected an attrs class"
# even if the type is correct.
for field in attrs.fields(cls): # type: ignore[misc]
for field in attrs.fields(cls):
if field.init:
key_word = field.name[1:] if field.name.startswith("_") else field.name
init_results.append((field, key_word))
Expand Down
54 changes: 29 additions & 25 deletions hikari/internal/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,19 +203,21 @@ def __new__(

for name, value in namespace.names_to_values.items():
member = new_namespace.get(name)
if not isinstance(member, _DeprecatedAlias):
# Patching the member init call is around 100ns faster per call than
# using the default type.__call__ which would make us do the lookup
# in cls.__new__. Reason for this is that python will also always
# invoke cls.__init__ if we do this, so we end up with two function
# calls.
member = cls.__new__(cls, value)
member._name_ = name
member._value_ = value
setattr(cls, name, member)
if isinstance(member, _DeprecatedAlias):
continue

# Patching the member init call is around 100ns faster per call than
# using the default type.__call__ which would make us do the lookup
# in cls.__new__. Reason for this is that python will also always
# invoke cls.__init__ if we do this, so we end up with two function
# calls.
member = cls.__new__(cls, value)
member._name_ = name
member._value_ = value
setattr(cls, name, member)

name_to_member[name] = member
value_to_member.setdefault(value, member)
value_to_member[value] = member
member_names.append(name)

return cls
Expand Down Expand Up @@ -471,24 +473,26 @@ def __new__(

for name, value in namespace.names_to_values.items():
member = new_namespace.get(name)
if not isinstance(member, _DeprecatedAlias):
# Patching the member init call is around 100ns faster per call than
# using the default type.__call__ which would make us do the lookup
# in cls.__new__. Reason for this is that python will also always
# invoke cls.__init__ if we do this, so we end up with two function
# calls.
member = cls.__new__(cls, value)
member._name_ = name
member._value_ = value
setattr(cls, name, member)

if not (value & value - 1):
powers_of_2_map[value] = member
if isinstance(member, _DeprecatedAlias):
continue

# Patching the member init call is around 100ns faster per call than
# using the default type.__call__ which would make us do the lookup
# in cls.__new__. Reason for this is that python will also always
# invoke cls.__init__ if we do this, so we end up with two function
# calls.
member = cls.__new__(cls, value)
member._name_ = name
member._value_ = value
setattr(cls, name, member)

name_to_member[name] = member
value_to_member.setdefault(value, member)
value_to_member[value] = member
member_names.append(name)

if not (value & value - 1):
powers_of_2_map[value] = member

all_bits = functools.reduce(operator.or_, value_to_member.keys())
all_bits_member = cls.__new__(cls, all_bits)
all_bits_member._name_ = None
Expand Down
Loading

0 comments on commit 257e387

Please sign in to comment.