Skip to content

Commit

Permalink
Fix incorrectly replaced backticks in strings (#1866)
Browse files Browse the repository at this point in the history
  • Loading branch information
beagold committed Apr 1, 2024
1 parent 832f2ed commit d90c41c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions changes/1866.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix incorrectly formatted error strings
8 changes: 4 additions & 4 deletions hikari/impl/entity_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -1655,27 +1655,27 @@ def serialize_embed( # noqa: C901 - Function too complex
# Yep, these are technically two unreachable branches. However, this is an incredibly
# common mistake to make when working with embeds and not using a static type
# checker, so I have added these as additional safeguards for UX and ease
# of debugging. The case that there are [`None`][] should be detected immediately by
# of debugging. The case that there are `None` should be detected immediately by
# static type checkers, regardless.
name = str(field.name) if field.name is not None else None
value = str(field.value) if field.value is not None else None

if name is None:
raise TypeError(f"in embed.fields[{i}].name - cannot have [`None`][]")
raise TypeError(f"in embed.fields[{i}].name - cannot have `None`")
if not name:
raise TypeError(f"in embed.fields[{i}].name - cannot have empty string")
if not name.strip():
raise TypeError(f"in embed.fields[{i}].name - cannot have only whitespace")

if value is None:
raise TypeError(f"in embed.fields[{i}].value - cannot have [`None`][]")
raise TypeError(f"in embed.fields[{i}].value - cannot have `None`")
if not value:
raise TypeError(f"in embed.fields[{i}].value - cannot have empty string")
if not value.strip():
raise TypeError(f"in embed.fields[{i}].value - cannot have only whitespace")

# Name and value always have to be specified; we can always
# send a default [`inline`][] value also just to keep this simpler.
# send a default `inline` value also just to keep this simpler.
field_payloads.append({"name": name, "value": value, "inline": field.is_inline})
payload["fields"] = field_payloads

Expand Down
2 changes: 1 addition & 1 deletion hikari/internal/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def __prepare__(
return _EnumNamespace(object)

try:
# Fails if Enum is not defined. We check this in [`__new__`][] properly.
# Fails if Enum is not defined. We check this in `__new__` properly.
base, enum_type = bases

if isinstance(base, _EnumMeta):
Expand Down
2 changes: 1 addition & 1 deletion hikari/internal/ux.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ def warn_if_not_optimized(suppress: bool) -> None:
if __debug__ and not suppress:
_LOGGER.warning(
"You are running on optimization level 0 (no optimizations), which may slow down your application. "
"For production, consider using at least level 1 optimization by passing [-O][] to the python "
"For production, consider using at least level 1 optimization by passing `-O` to the python "
"interpreter call"
)

Expand Down

0 comments on commit d90c41c

Please sign in to comment.