diff options
author | 2021-03-25 15:03:53 +0100 | |
---|---|---|
committer | 2021-03-25 15:03:53 +0100 | |
commit | bb5054c1aa8abcbd91a524bb532d2677f2029d97 (patch) | |
tree | 51a55f048d9fafafa6bbfd38ca490118c5ced7c7 | |
parent | Replace shorten with custom algo to find good cutoff points (diff) |
swap single quotes to double quotes where they were unnecessary
-rw-r--r-- | bot/exts/info/doc/_cog.py | 24 | ||||
-rw-r--r-- | bot/exts/info/doc/_inventory_parser.py | 12 | ||||
-rw-r--r-- | bot/exts/info/doc/_parsing.py | 4 |
3 files changed, 20 insertions, 20 deletions
diff --git a/bot/exts/info/doc/_cog.py b/bot/exts/info/doc/_cog.py index 5af95717b..a06bfcbaf 100644 --- a/bot/exts/info/doc/_cog.py +++ b/bot/exts/info/doc/_cog.py @@ -213,7 +213,7 @@ class DocCog(commands.Cog): coros = [ self.update_or_reschedule_inventory( package["package"], package["base_url"], package["inventory_url"] - ) for package in await self.bot.api_client.get('bot/documentation-links') + ) for package in await self.bot.api_client.get("bot/documentation-links") ] await asyncio.gather(*coros) log.debug("Finished inventory refresh.") @@ -283,8 +283,8 @@ class DocCog(commands.Cog): # Show all symbols with the same name that were renamed in the footer, # with a max of 100 chars. if symbol_name in self.renamed_symbols: - renamed_symbols = ', '.join(self.renamed_symbols[symbol_name]) - footer_text = textwrap.shorten("Moved: " + renamed_symbols, 200, placeholder=' ...') + renamed_symbols = ", ".join(self.renamed_symbols[symbol_name]) + footer_text = textwrap.shorten("Moved: " + renamed_symbols, 200, placeholder=" ...") else: footer_text = "" @@ -296,12 +296,12 @@ class DocCog(commands.Cog): embed.set_footer(text=footer_text) return embed - @commands.group(name='docs', aliases=('doc', 'd'), invoke_without_command=True) + @commands.group(name="docs", aliases=("doc", "d"), invoke_without_command=True) async def docs_group(self, ctx: commands.Context, *, symbol_name: Optional[str]) -> None: """Look up documentation for Python symbols.""" await self.get_command(ctx, symbol_name=symbol_name) - @docs_group.command(name='getdoc', aliases=('g',)) + @docs_group.command(name="getdoc", aliases=("g",)) async def get_command(self, ctx: commands.Context, *, symbol_name: Optional[str]) -> None: """ Return a documentation embed for a given symbol. @@ -344,7 +344,7 @@ class DocCog(commands.Cog): msg = await ctx.send(embed=doc_embed) await wait_for_deletion(msg, (ctx.author.id,)) - @docs_group.command(name='setdoc', aliases=('s',)) + @docs_group.command(name="setdoc", aliases=("s",)) @commands.has_any_role(*MODERATION_ROLES) @lock(NAMESPACE, COMMAND_LOCK_SINGLETON, raise_error=True) async def set_command( @@ -367,11 +367,11 @@ class DocCog(commands.Cog): """ inventory_url, inventory_dict = inventory body = { - 'package': package_name, - 'base_url': base_url, - 'inventory_url': inventory_url + "package": package_name, + "base_url": base_url, + "inventory_url": inventory_url } - await self.bot.api_client.post('bot/documentation-links', json=body) + await self.bot.api_client.post("bot/documentation-links", json=body) log.info( f"User @{ctx.author} ({ctx.author.id}) added a new documentation package:\n" @@ -381,7 +381,7 @@ class DocCog(commands.Cog): self.update_single(package_name, base_url, inventory_dict) await ctx.send(f"Added the package `{package_name}` to the database and updated the inventories.") - @docs_group.command(name='deletedoc', aliases=('removedoc', 'rm', 'd')) + @docs_group.command(name="deletedoc", aliases=("removedoc", "rm", "d")) @commands.has_any_role(*MODERATION_ROLES) @lock(NAMESPACE, COMMAND_LOCK_SINGLETON, raise_error=True) async def delete_command(self, ctx: commands.Context, package_name: PackageName) -> None: @@ -391,7 +391,7 @@ class DocCog(commands.Cog): Example: !docs deletedoc aiohttp """ - await self.bot.api_client.delete(f'bot/documentation-links/{package_name}') + await self.bot.api_client.delete(f"bot/documentation-links/{package_name}") async with ctx.typing(): await self.refresh_inventories() diff --git a/bot/exts/info/doc/_inventory_parser.py b/bot/exts/info/doc/_inventory_parser.py index 1615f15bd..80d5841a0 100644 --- a/bot/exts/info/doc/_inventory_parser.py +++ b/bot/exts/info/doc/_inventory_parser.py @@ -50,12 +50,12 @@ async def _load_v1(stream: aiohttp.StreamReader) -> InventoryDict: async for line in stream: name, type_, location = line.decode().rstrip().split(maxsplit=2) # version 1 did not add anchors to the location - if type_ == 'mod': - type_ = 'py:module' - location += '#module-' + name + if type_ == "mod": + type_ = "py:module" + location += "#module-" + name else: - type_ = 'py:' + type_ - location += '#' + name + type_ = "py:" + type_ + location += "#" + name invdata[type_].append((name, location)) return invdata @@ -66,7 +66,7 @@ async def _load_v2(stream: aiohttp.StreamReader) -> InventoryDict: async for line in ZlibStreamReader(stream): m = _V2_LINE_RE.match(line.rstrip()) name, type_, _prio, location, _dispname = m.groups() # ignore the parsed items we don't need - if location.endswith('$'): + if location.endswith("$"): location = location[:-1] + name invdata[type_].append((name, location)) diff --git a/bot/exts/info/doc/_parsing.py b/bot/exts/info/doc/_parsing.py index b3402f655..bf840b96f 100644 --- a/bot/exts/info/doc/_parsing.py +++ b/bot/exts/info/doc/_parsing.py @@ -224,7 +224,7 @@ def _create_markdown(signatures: Optional[List[str]], description: Iterable[Tag] max_length=750, max_lines=13 ) - description = _WHITESPACE_AFTER_NEWLINES_RE.sub('', description) + description = _WHITESPACE_AFTER_NEWLINES_RE.sub("", description) if signatures is not None: signature = "".join(f"```py\n{signature}```" for signature in _truncate_signatures(signatures)) return f"{signature}\n{description}" @@ -253,4 +253,4 @@ def get_symbol_markdown(soup: BeautifulSoup, symbol_data: DocItem) -> Optional[s else: signature = get_signatures(symbol_heading) description = get_dd_description(symbol_heading) - return _create_markdown(signature, description, symbol_data.url).replace('¶', '').strip() + return _create_markdown(signature, description, symbol_data.url).replace("¶", "").strip() |