Skip to content

Commit

Permalink
Merge branch 'V3/develop' into pylint_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Kreusada authored Nov 17, 2024
2 parents ebb7eae + 2871992 commit c1028ac
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 15 deletions.
12 changes: 8 additions & 4 deletions redbot/cogs/downloader/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,14 +648,18 @@ async def _repo_list(self, ctx: commands.Context) -> None:
joined = _("There are no repos installed.")
else:
if len(repos) > 1:
joined = _("# Installed Repos\n")
joined = _("## Installed Repos\n")
else:
joined = _("# Installed Repo\n")
joined = _("## Installed Repo\n")
for repo in sorted_repos:
joined += "+ {}: {}\n".format(repo.name, repo.short or "")
joined += "- **{}:** {}\n - {}\n".format(
repo.name,
repo.short or "",
"<{}>".format(repo.url),
)

for page in pagify(joined, ["\n"], shorten_by=16):
await ctx.send(box(page.lstrip(" "), lang="markdown"))
await ctx.send(page)

@repo.command(name="info")
async def _repo_info(self, ctx: commands.Context, repo: Repo) -> None:
Expand Down
6 changes: 4 additions & 2 deletions redbot/cogs/trivia/data/lists/harrypotter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ What are draco's parents' names?:
- Narcissa and Lucious
What book does Hermione insist Ron and Harry read?:
- Hogwarts, A History
- Hogwarts A History
What breed was Hagrid's pet dragon?:
- Norwegian Ridgeback
What color are unicorn foals?:
Expand Down Expand Up @@ -194,7 +195,7 @@ What is Severus Snape's mother's first name?:
What is Tonks's first name?:
- Nymphadora
What is considered Harry's 'trademark spell'?:
- Expelliarmus.
- Expelliarmus
What is the Hogwarts School motto in English?:
- Never Tickle a Sleeping Dragon
What is the age requirement for an Apparation License?:
Expand Down Expand Up @@ -222,6 +223,7 @@ What is the name of Dumbledore's phoenix?:
- fawkes
What is the name of Filch's cat?:
- Mrs. Norris
- Mrs Norris
What is the name of Harry Potter’s pet owl?:
- Hedwig
What is the name of Harry's aunt?:
Expand Down Expand Up @@ -609,4 +611,4 @@ How many hours into the past do Harry and Hermione travel in an attempt to rescu
- Three
How many muggles did Peter Pettigrew kill when he faked his own death?:
- 12
- Twelve
- Twelve
17 changes: 10 additions & 7 deletions redbot/cogs/trivia/trivia.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

UNIQUE_ID = 0xB3C0E453
_ = Translator("Trivia", __file__)
YAMLSafeLoader = getattr(yaml, "CSafeLoader", yaml.SafeLoader)


class InvalidListError(Exception):
Expand Down Expand Up @@ -759,7 +760,7 @@ async def _save_trivia_list(
return

buffer = io.BytesIO(await attachment.read())
trivia_dict = yaml.safe_load(buffer)
trivia_dict = yaml.load(buffer, YAMLSafeLoader)
TRIVIA_LIST_SCHEMA.validate(trivia_dict)

buffer.seek(0)
Expand Down Expand Up @@ -803,7 +804,7 @@ def get_core_lists() -> List[pathlib.Path]:
return list(core_lists_path.glob("*.yaml"))


def get_list(path: pathlib.Path) -> Dict[str, Any]:
def get_list(path: pathlib.Path, *, validate_schema: bool = True) -> Dict[str, Any]:
"""
Returns a trivia list dictionary from the given path.
Expand All @@ -814,12 +815,14 @@ def get_list(path: pathlib.Path) -> Dict[str, Any]:
"""
with path.open(encoding="utf-8") as file:
try:
trivia_dict = yaml.safe_load(file)
trivia_dict = yaml.load(file, YAMLSafeLoader)
except yaml.error.YAMLError as exc:
raise InvalidListError("YAML parsing failed.") from exc

try:
TRIVIA_LIST_SCHEMA.validate(trivia_dict)
except schema.SchemaError as exc:
raise InvalidListError("The list does not adhere to the schema.") from exc
if validate_schema:
try:
TRIVIA_LIST_SCHEMA.validate(trivia_dict)
except schema.SchemaError as exc:
raise InvalidListError("The list does not adhere to the schema.") from exc

return trivia_dict
6 changes: 6 additions & 0 deletions redbot/core/_cog_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,12 @@ async def _find_core_cog(name: str) -> ModuleSpec:

try:
mod = import_module(real_name, package=package)
if mod.__spec__.name == "redbot.cogs.locales":
raise NoSuchCog(
"No core cog by the name of '{}' could be found.".format(name),
path=mod.__spec__.origin,
name=name,
)
except ImportError as e:
if e.name == package + real_name:
raise NoSuchCog(
Expand Down
3 changes: 1 addition & 2 deletions redbot/core/utils/menus.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,12 @@ async def control_no(*args, **kwargs):
# where the original message is already sent prior to starting.
# This is not normally the way we recommend sending this because
# internally we already include the emojis we expect.
view = SimpleMenu(pages, timeout=timeout)
if controls == DEFAULT_CONTROLS:
view = SimpleMenu(pages, timeout=timeout)
await view.start(ctx, user=user)
await view.wait()
return
else:
view = SimpleMenu(pages, timeout=timeout)
view.remove_item(view.last_button)
view.remove_item(view.first_button)
has_next = False
Expand Down

0 comments on commit c1028ac

Please sign in to comment.