Skip to content

Commit cb577c0

Browse files
committed
Fix up exec comment to please ruff
1 parent 07f3af0 commit cb577c0

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/scyjava/_script.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,16 @@ def apply(self, arg):
9090
):
9191
# Last statement looks like an expression. Evaluate!
9292
last = ast.Expression(block.body.pop().value)
93-
# See here for why this implementation: https://docs.python.org/3/library/functions.html#exec
94-
# When `exec` gets two separate objects as *globals* and *locals*, the code will be executed as if it were embedded in a class definition.
95-
# This means functions and classes defined in the executed code will not be able to access variables assigned at the top level
96-
# (as the “top level” variables are treated as class variables in a class definition).
93+
94+
# NB: When `exec` gets two separate objects as *globals* and
95+
# *locals*, the code will be executed as if it were embedded in
96+
# a class definition. This means functions and classes defined
97+
# in the executed code will not be able to access variables
98+
# assigned at the top level, because the "top level" variables
99+
# are treated as class variables in a class definition.
100+
# See: https://docs.python.org/3/library/functions.html#exec
97101
_globals = script_locals
102+
98103
exec(
99104
compile(block, "<string>", mode="exec"), _globals, script_locals
100105
)

0 commit comments

Comments
 (0)