Skip to content

Commit

Permalink
Merge branch 'master' into refactor/app-commands
Browse files Browse the repository at this point in the history
  • Loading branch information
onerandomusername committed Aug 14, 2022
2 parents 3d1a96d + 1ee0b31 commit c0c3554
Show file tree
Hide file tree
Showing 57 changed files with 1,057 additions and 460 deletions.
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ per-file-ignores =
disnake/player.py:S404,S603
# ignore whitespacing after `:`
disnake/ext/commands/params.py:E241
# upstream bug: https://github.com/PyCQA/bandit/issues/926
disnake/backoff.py:S311
disnake/colour.py:S311
# pytest uses assert for testing
tests/**: S101
# ignore pytest issues outside of tests directory
Expand All @@ -58,6 +61,7 @@ per-file-ignores =
# S311: examples don't misuse random generation
# S105: possible hardcoded passwords TODO
examples/**:B008,S311,S105
test_bot/**:B008
# usage of assert and interface binding, allowable for the third party lib at use
# also have to reignore whatever is from the last check that pops up here
examples/basic_voice.py:S101,S104
Expand Down
16 changes: 14 additions & 2 deletions .github/workflows/lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ jobs:
warnings: true


slotscheck:
checks:
# We want to run on external PRs, but not on our own internal PRs as they'll be run
# by the push to the branch. Without this if check, checks are duplicated since
# internal PRs match both the push and pull_request events.
Expand All @@ -131,13 +131,25 @@ jobs:
- uses: actions/checkout@v3

- name: Set up environment
id: setup
uses: ./.github/actions/setup-env
with:
python-version: 3.8
nox-setup: tools

- name: Run slotscheck
run: task slotscheck
if: (success() || failure()) && steps.setup.outcome == 'success'
run: nox -s slotscheck

- name: Run check-manifest
if: (success() || failure()) && steps.setup.outcome == 'success'
run: nox -s check-manifest

# This only runs if the previous steps were successful, no point in running it otherwise
- name: Build package
run: |
pip install -U build
python -m build
pytest:
# Thanks to black for this rule
Expand Down
20 changes: 14 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,39 @@ repos:
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]

- repo: local
hooks:
- id: no-symlinks
name: no symlinks
description: "Check for symlinks"
entry: "symlinks may not be committed due to platform support"
language: fail
types: [symlink]

- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
args: ["--profile", "black", "--extend-skip", "examples"]
name: Running isort in all files.
name: "run isort in all files"
exclude: ^examples/
- id: isort
args: ["--profile", "black", "--thirdparty", "disnake"]
name: Running isort in examples.
name: "run isort in examples"
files: ^examples/

- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
name: Running black in all files.
name: "run black in all files"

- repo: local
hooks:
- id: flake8
name: flake8
description: 'Lint all of our code'
description: "Lint all of our code"
entry: flake8
exclude: ^test_bot/
language: python
language: system
types: [python]
require_serial: true
5 changes: 3 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
include README.md
include LICENSE
include requirements.txt
include disnake/bin/*.dll
include disnake/bin/*
include disnake/py.typed
recursive-include . requirements*.txt
global-exclude *.py[cod]
1 change: 1 addition & 0 deletions changelog/488.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Properly close sockets when receiving a voice server update event.
1 change: 1 addition & 0 deletions changelog/590.breaking.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Rename ``channel_id`` parameter to ``channel`` on :attr:`Guild.create_scheduled_event` and :meth:`GuildScheduledEvent.edit`.
1 change: 1 addition & 0 deletions changelog/590.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allow ``entity_type`` parameter :attr:`Guild.create_scheduled_event` to be missing.
1 change: 1 addition & 0 deletions changelog/594.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add typings for all gateway payloads.
1 change: 0 additions & 1 deletion changelog/615.feature.rst

This file was deleted.

6 changes: 6 additions & 0 deletions changelog/615.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Add support of more operators to all ``Flag`` classes. This list includes :class:`Intents` and :class:`Permissions`.
- ``&``, ``|``, ``^``, and ``~`` bitwise operator support.
- ``<``, ``<=``, ``>``, and ``>=`` comparsion operator support.
- Support ``|`` operators between flag instances and flag values.
- Support ``~`` operator on flag values, which create a flag instance with all except this specific flag enabled.
- Support ``|`` operators between flag values which create a flag instance with both flag values enabled.
1 change: 0 additions & 1 deletion changelog/648.doc.rst

This file was deleted.

1 change: 1 addition & 0 deletions changelog/648.doc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update :attr:`InteractionReference.name` description, now includes group and subcommand.
1 change: 1 addition & 0 deletions changelog/660.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove the internal ``fill_with_flags`` decorator for flags classes and use the built in :meth:`object.__init_subclass__` method.
1 change: 1 addition & 0 deletions changelog/671.doc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update fields listed in :func:`on_user_update` and :func:`on_member_update` docs.
1 change: 1 addition & 0 deletions changelog/672.breaking.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Change the default of the ``ignore_timeout`` parameter for all ``permissions_for`` methods to ``False``.
1 change: 1 addition & 0 deletions changelog/689.deprecate.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
|commands| Using ``command_prefix=None`` with :class:`~disnake.ext.commands.Bot` is now deprecated in favour of :class:`~disnake.ext.commands.InteractionBot`.
1 change: 1 addition & 0 deletions changelog/689.doc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
|commands| Improve documentation around using ``None`` for :attr:`Bot.command_prefix <disnake.ext.commands.Bot.command_prefix>`.
1 change: 1 addition & 0 deletions changelog/690.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve parallel documentation build speed.
1 change: 1 addition & 0 deletions changelog/702.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Limit installation of ``cchardet`` in the ``[speed]`` extra to Python versions below 3.10 (see `aiohttp#6857 <https://github.com/aio-libs/aiohttp/pull/6857>`__).
8 changes: 6 additions & 2 deletions disnake/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,14 +624,18 @@ def permissions_for(
are not computed.
ignore_timeout: :class:`bool`
Whether or not to ignore the user's timeout.
Defaults to ``True`` for backwards compatibility.
Defaults to ``False``.
.. versionadded:: 2.4
.. note::
This only applies to :class:`~disnake.Member` objects.
.. versionchanged:: 2.6
The default was changed to ``False``.
Raises
------
TypeError
Expand Down Expand Up @@ -660,7 +664,7 @@ def permissions_for(
raise TypeError("ignore_timeout is only supported for disnake.Member objects")

if ignore_timeout is MISSING:
ignore_timeout = True
ignore_timeout = False

if self.guild.owner_id == obj.id:
return Permissions.all()
Expand Down
4 changes: 2 additions & 2 deletions disnake/automod.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
from .threads import Thread
from .types.automod import (
AutoModAction as AutoModActionPayload,
AutoModActionExecutionEvent as AutoModActionExecutionEventPayload,
AutoModActionMetadata,
AutoModBlockMessageActionMetadata,
AutoModRule as AutoModRulePayload,
Expand All @@ -69,6 +68,7 @@
AutoModTriggerMetadata as AutoModTriggerMetadataPayload,
EditAutoModRule as EditAutoModRulePayload,
)
from .types.gateway import AutoModerationActionExecutionEvent

__all__ = (
"AutoModAction",
Expand Down Expand Up @@ -634,7 +634,7 @@ class AutoModActionExecution:
"matched_content",
)

def __init__(self, *, data: AutoModActionExecutionEventPayload, guild: Guild) -> None:
def __init__(self, *, data: AutoModerationActionExecutionEvent, guild: Guild) -> None:
self.guild: Guild = guild
self.action: AutoModAction = _automod_action_factory(data["action"])
self.rule_id: int = int(data["rule_id"])
Expand Down
5 changes: 5 additions & 0 deletions disnake/ext/commands/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ class Bot(BotBase, InteractionBotBase, disnake.Client):
:attr:`.Context.prefix`. To avoid confusion empty iterables are not
allowed.
If the prefix is ``None``, the bot won't listen to any prefixes, and prefix
commands will not be processed. If you don't need prefix commands, consider
using :class:`InteractionBot` or :class:`AutoShardedInteractionBot` instead,
which are drop-in replacements, just without prefix command support.
.. note::
When passing multiple prefixes be careful to not pass a prefix
Expand Down
35 changes: 26 additions & 9 deletions disnake/ext/commands/bot_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,28 +150,45 @@ def __init__(
**options: Any,
):
super().__init__(**options)
self.command_prefix = command_prefix
if (

if not isinstance(self, disnake.Client):
raise RuntimeError("BotBase mixin must be used with disnake.Client")

alternative = (
"AutoShardedInteractionBot"
if isinstance(self, disnake.AutoShardedClient)
else "InteractionBot"
)
if command_prefix is None:
disnake.utils.warn_deprecated(
"Using `command_prefix=None` is deprecated and will result in "
"an error in future versions. "
f"If you don't need any prefix functionality, consider using {alternative}.",
stacklevel=2,
)
elif (
# note: no need to check for empty iterables,
# as they won't be allowed by `get_prefix`
command_prefix is not when_mentioned
and not self.intents.message_content # type: ignore
and not self.intents.message_content
):

warnings.warn(
"Message Content intent is not enabled and a prefix is configured. "
"This may cause limited functionality for prefix commands. "
"If you want prefix commands, pass an intents object with message_content set to True. "
"If you don't need any prefix functionality, "
"consider using InteractionBot instead. "
f"If you don't need any prefix functionality, consider using {alternative}. "
"Alternatively, set prefix to disnake.ext.commands.when_mentioned to silence this warning.",
MessageContentPrefixWarning,
stacklevel=2,
)

self.command_prefix = command_prefix

self._checks: List[Check] = []
self._check_once = []
self._check_once: List[Check] = []

self._before_invoke = None
self._after_invoke = None
self._before_invoke: Optional[CoroFunc] = None
self._after_invoke: Optional[CoroFunc] = None

self._help_command = None
self.description: str = inspect.cleandoc(description) if description else ""
Expand Down
3 changes: 1 addition & 2 deletions disnake/ext/commands/flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@

from typing import TYPE_CHECKING

from disnake.flags import BaseFlags, alias_flag_value, all_flags_value, fill_with_flags, flag_value
from disnake.flags import BaseFlags, alias_flag_value, all_flags_value, flag_value

if TYPE_CHECKING:
from typing_extensions import Self

__all__ = ("ApplicationCommandSyncFlags",)


@fill_with_flags()
class ApplicationCommandSyncFlags(BaseFlags):
"""Controls the library's application command syncing policy.
Expand Down
Loading

0 comments on commit c0c3554

Please sign in to comment.