Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove obsolete __future__ imports #3668

Merged
merged 1 commit into from
Jul 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/2319.trivial.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove obsolete ``__future__`` imports.
13 changes: 3 additions & 10 deletions src/_pytest/_code/source.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from __future__ import absolute_import, division, generators, print_function
from __future__ import absolute_import, division, print_function

import ast
from ast import PyCF_ONLY_AST as _AST_FLAG
Expand Down Expand Up @@ -152,12 +152,7 @@ def __str__(self):
return "\n".join(self.lines)

def compile(
self,
filename=None,
mode="exec",
flag=generators.compiler_flag,
dont_inherit=0,
_genframe=None,
self, filename=None, mode="exec", flag=0, dont_inherit=0, _genframe=None
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(harder to see the change here since black reformatted it, essentially this:

-    flag=generators.compiler_flag,
+    flag=0,

this is the same as the default builtin compile(...) function -- and in versions newer than python2.3 the generators flag is ignored so the two are equivalent

):
""" return compiled code object. if filename is None
invent an artificial filename which displays
Expand Down Expand Up @@ -201,9 +196,7 @@ def compile(
#


def compile_(
source, filename=None, mode="exec", flags=generators.compiler_flag, dont_inherit=0
):
def compile_(source, filename=None, mode="exec", flags=0, dont_inherit=0):
""" compile the given source to a raw code object,
and maintain an internal cache which allows later
retrieval of the source code for the code object
Expand Down
3 changes: 1 addition & 2 deletions testing/python/raises.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ def __call__(self):
def test_raises_as_contextmanager(self, testdir):
testdir.makepyfile(
"""
from __future__ import with_statement
import py, pytest
import pytest
import _pytest._code

def test_simple():
Expand Down
6 changes: 3 additions & 3 deletions testing/test_assertrewrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,23 +97,23 @@ def test_place_initial_imports(self):
assert imp.lineno == 2
assert imp.col_offset == 0
assert isinstance(m.body[2], ast.Assign)
s = """from __future__ import with_statement\nother_stuff"""
s = """from __future__ import division\nother_stuff"""
m = rewrite(s)
assert isinstance(m.body[0], ast.ImportFrom)
for imp in m.body[1:3]:
assert isinstance(imp, ast.Import)
assert imp.lineno == 2
assert imp.col_offset == 0
assert isinstance(m.body[3], ast.Expr)
s = """'doc string'\nfrom __future__ import with_statement"""
s = """'doc string'\nfrom __future__ import division"""
m = rewrite(s)
adjust_body_for_new_docstring_in_module_node(m)
assert isinstance(m.body[0], ast.ImportFrom)
for imp in m.body[1:3]:
assert isinstance(imp, ast.Import)
assert imp.lineno == 2
assert imp.col_offset == 0
s = """'doc string'\nfrom __future__ import with_statement\nother"""
s = """'doc string'\nfrom __future__ import division\nother"""
m = rewrite(s)
adjust_body_for_new_docstring_in_module_node(m)
assert isinstance(m.body[0], ast.ImportFrom)
Expand Down
1 change: 0 additions & 1 deletion testing/test_capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

# note: py.io capture tests where copied from
# pylib 1.4.20.dev2 (rev 13d9af95547e)
from __future__ import with_statement
import pickle
import os
import sys
Expand Down