diff options
| author | 2023-05-09 16:01:01 +0100 | |
|---|---|---|
| committer | 2023-05-09 16:01:01 +0100 | |
| commit | c3e23e60278d34658f801bd7d7ed721d5a272637 (patch) | |
| tree | e159a0fae7850d706d713cf2b49dfed2140ce655 /bot/exts/core/internal_eval | |
| parent | Bump sentry-sdk from 1.21.1 to 1.22.1 (#1273) (diff) | |
| parent | Move unshared contants inside modules (diff) | |
Merge pull request #1270 from python-discord/migrate-to-ruff
Migrate to ruff
Diffstat (limited to 'bot/exts/core/internal_eval')
| -rw-r--r-- | bot/exts/core/internal_eval/_helpers.py | 10 | ||||
| -rw-r--r-- | bot/exts/core/internal_eval/_internal_eval.py | 3 | 
2 files changed, 6 insertions, 7 deletions
| diff --git a/bot/exts/core/internal_eval/_helpers.py b/bot/exts/core/internal_eval/_helpers.py index 5b2f8f5d..34ef7fef 100644 --- a/bot/exts/core/internal_eval/_helpers.py +++ b/bot/exts/core/internal_eval/_helpers.py @@ -8,7 +8,7 @@ import logging  import sys  import traceback  import types -from typing import Any, Optional, Union +from typing import Any  log = logging.getLogger(__name__) @@ -120,7 +120,7 @@ class EvalContext:          log.trace(f"Updating {self._locals} with {locals_}")          self._locals.update(locals_) -    def prepare_eval(self, code: str) -> Optional[str]: +    def prepare_eval(self, code: str) -> str | None:          """Prepare an evaluation by processing the code and setting up the context."""          self.code = code @@ -149,7 +149,7 @@ class EvalContext:          compiled_code = compile(self.eval_tree, filename=INTERNAL_EVAL_FRAMENAME, mode="exec")          log.trace("Executing the compiled code with the desired namespace environment") -        exec(compiled_code, self.locals)  # noqa: B102,S102 +        exec(compiled_code, self.locals)  # noqa: S102          log.trace("Awaiting the created evaluation wrapper coroutine.")          await self.function() @@ -212,7 +212,7 @@ class CaptureLastExpression(ast.NodeTransformer):          self.tree = tree          self.last_node = list(ast.iter_child_nodes(tree))[-1] -    def visit_Expr(self, node: ast.Expr) -> Union[ast.Expr, ast.Assign]:  # noqa: N802 +    def visit_Expr(self, node: ast.Expr) -> ast.Expr | ast.Assign:  # noqa: N802          """          Replace the Expr node that is last child node of Module with an assignment. @@ -230,7 +230,7 @@ class CaptureLastExpression(ast.NodeTransformer):          right_hand_side = list(ast.iter_child_nodes(node))[0]          assignment = ast.Assign( -            targets=[ast.Name(id='_value_last_expression', ctx=ast.Store())], +            targets=[ast.Name(id="_value_last_expression", ctx=ast.Store())],              value=right_hand_side,              lineno=node.lineno,              col_offset=0, diff --git a/bot/exts/core/internal_eval/_internal_eval.py b/bot/exts/core/internal_eval/_internal_eval.py index 2daf8ef9..f5188c1f 100644 --- a/bot/exts/core/internal_eval/_internal_eval.py +++ b/bot/exts/core/internal_eval/_internal_eval.py @@ -1,7 +1,6 @@  import logging  import re  import textwrap -from typing import Optional  import discord  from discord.ext import commands @@ -84,7 +83,7 @@ class InternalEval(commands.Cog):          return shortened_output -    async def _upload_output(self, output: str) -> Optional[str]: +    async def _upload_output(self, output: str) -> str | None:          """Upload `internal eval` output to our pastebin and return the url."""          data = self.shorten_output(output, max_length=MAX_LENGTH)          try: | 
