Skip to content

Commit

Permalink
fixup comments
Browse files Browse the repository at this point in the history
  • Loading branch information
hauntsaninja committed Apr 12, 2021
1 parent da66f00 commit e3dc34e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/_pytest/assertion/rewrite.py
Expand Up @@ -685,8 +685,8 @@ def run(self, mod: ast.Module) -> None:
# Nothing to do.
return

# Insert some special imports at the top of the module but after any
# docstrings and __future__ imports.
# We'll insert some special imports at the top of the module, but after any
# docstrings and __future__ imports, so first figure out where that is.
doc = getattr(mod, "docstring", None)
expect_docstring = doc is None
if doc is not None and self.is_rewrite_disabled(doc):
Expand Down Expand Up @@ -718,6 +718,7 @@ def run(self, mod: ast.Module) -> None:
lineno = item.decorator_list[0].lineno
else:
lineno = item.lineno
# Now actually insert the special imports.
if sys.version_info >= (3, 10):
aliases = [
ast.alias("builtins", "@py_builtins", lineno=lineno, col_offset=0),
Expand All @@ -737,6 +738,7 @@ def run(self, mod: ast.Module) -> None:
ast.Import([alias], lineno=lineno, col_offset=0) for alias in aliases
]
mod.body[pos:pos] = imports

# Collect asserts.
nodes: List[ast.AST] = [mod]
while nodes:
Expand Down

0 comments on commit e3dc34e

Please sign in to comment.