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

Fix errors that will occur in python3.11 #1680

Merged
merged 1 commit into from
Oct 14, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions discord/ext/commands/flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from dataclasses import dataclass, field
from typing import TYPE_CHECKING, Any, Iterator, Literal, Pattern, TypeVar, Union

from discord.utils import MISSING, maybe_coroutine, resolve_annotation
from discord.utils import MISSING, MissingField, maybe_coroutine, resolve_annotation

from .converter import run_converters
from .errors import (
Expand Down Expand Up @@ -81,13 +81,13 @@ class Flag:
Whether multiple given values overrides the previous value.
"""

name: str = MISSING
name: str = MissingField
aliases: list[str] = field(default_factory=list)
attribute: str = MISSING
annotation: Any = MISSING
default: Any = MISSING
max_args: int = MISSING
override: bool = MISSING
attribute: str = MissingField
annotation: Any = MissingField
default: Any = MissingField
max_args: int = MissingField
override: bool = MissingField
cast_to_dict: bool = False

@property
Expand Down
6 changes: 6 additions & 0 deletions discord/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import warnings
from base64 import b64encode
from bisect import bisect_left
from dataclasses import field
from inspect import isawaitable as _isawaitable
from inspect import signature as _signature
from operator import attrgetter
Expand Down Expand Up @@ -114,6 +115,11 @@ def __repr__(self) -> str:


MISSING: Any = _MissingSentinel()
# As of 3.11, directly setting a dataclass field to MISSING causes a ValueError. Using
# field(default=MISSING) produces the same error, but passing a lambda to
# default_factory produces the same behavior as default=MISSING and does not raise an
# error.
MissingField = field(default_factory=lambda: MISSING)


class _cached_property:
Expand Down