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

Adding Python 3 support #10

Merged
merged 212 commits into from
May 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
212 commits
Select commit Hold shift + click to select a range
728c740
Run futurize -1 -w -n lib/python/pyflyby/
asmeurer Mar 21, 2019
93d69a6
Run futurize -1 -w -n tests/
asmeurer Mar 21, 2019
b218b62
Selected fixes from futurize -2 -w -n lib/python/pyflyby/
asmeurer Mar 21, 2019
0699e29
Selected changes from futurize -2 -w -n tests/
asmeurer Mar 21, 2019
1463e73
Add cmp to pyflyby._util
asmeurer Mar 21, 2019
75a51c5
Fix pyflakes errors in Python 3 in pyflyby
asmeurer Mar 21, 2019
d064534
Fix pyflakes errors in tests/
asmeurer Mar 21, 2019
d01ee26
Merge branch 'tests-fix' into python3
asmeurer Apr 5, 2019
3b6adb5
Don't try to install epydoc in Python 2 on Travis
asmeurer Apr 5, 2019
b642ac8
Skip the docxref test in Python 3
asmeurer Apr 5, 2019
4bd09bc
Do not do automatic string formatting in ipython() in test_interactive
asmeurer Apr 5, 2019
8381580
Fix docxref tests skipping logic
asmeurer Apr 5, 2019
d3e3f4e
Run futurize -1 -w -n bin/*
asmeurer Apr 5, 2019
7065f9f
Run futurize -2 -w -n bin/*
asmeurer Apr 5, 2019
6f22176
Fix code in util that deals with unbound methods
asmeurer Apr 5, 2019
b93f7ee
Revert an incorrect futurize change
asmeurer Apr 5, 2019
e84d088
Fix the livepatch tests in Python 2
asmeurer Apr 5, 2019
27d0b0d
Fix test_py in Python 2.
asmeurer Apr 5, 2019
2be2483
Fix the docxref tests to correctly skip in Python 3
asmeurer Apr 5, 2019
44e6581
Merge branch 'master' into python3
asmeurer Apr 5, 2019
a69e23b
Remove Python 3 from the allowed failures on Travis
asmeurer Apr 5, 2019
7bafdbf
Fix test_0testconfig for Python 3
asmeurer Apr 5, 2019
d69e176
Define comparison methods on DottedIdentifier
asmeurer Apr 5, 2019
05e6629
Fix several autoimp tests that were testing with invalid syntax in Py…
asmeurer Apr 5, 2019
11d79cd
Fix some autoimp tests for Python 3 (b64decode returns a bytes object)
asmeurer Apr 5, 2019
4a31b5f
Skip doctesting for _docxref.py in Python 3
asmeurer Apr 5, 2019
fe74ae2
Fix the CompilerFlags doctests
asmeurer Apr 8, 2019
ff16cc1
Run pyflakes on everything except for imports files on Travis
asmeurer Apr 8, 2019
73113e3
Start fixing some doctests in _autoimp.py for Python 3
asmeurer Apr 8, 2019
8dfb2e2
Change launch_ipython_with_autoimporter to start_ipython_with_autoimp…
asmeurer Apr 8, 2019
97a54d8
Use flake8 --select=F instead of pyflakes on Travis
asmeurer Apr 8, 2019
c078f32
Fix pyflakes errors
asmeurer Apr 8, 2019
98fc369
Fix print syntax in test_imports2s.py for Python 3
asmeurer Apr 8, 2019
0284e46
Fix print statements to functions in doctests
asmeurer Apr 8, 2019
d8c8b3f
Fix the doctests in Python 2
asmeurer Apr 8, 2019
68964ff
Replace deprecated open(..., 'U') with io.open
asmeurer Apr 8, 2019
1d416b2
Fix a string type check assertion to work with unicode
asmeurer Apr 8, 2019
9f5eb3a
Replace __builtin__ with six.moves.builtins in _dbg.py
asmeurer Apr 11, 2019
1ffe63c
Skip a print function syntax error test in Python 3
asmeurer Apr 11, 2019
d4a69e2
Fix test_livepatch.py tests to work in Python 3
asmeurer Apr 11, 2019
334e4e7
Fix some Python 2/3 issues in test_py.py
asmeurer Apr 11, 2019
27dc79b
Fix call to create_time() from psutil
asmeurer Apr 11, 2019
2993856
Fix tests in test_parse.py for Python 3
asmeurer Apr 11, 2019
81ff951
Fix a 2/3 compatibility in a test
asmeurer Apr 11, 2019
1001484
Remove some commented out code
asmeurer Apr 11, 2019
d395ba3
Fix the remaining Python 3 test failures in test_parse.py
asmeurer Apr 11, 2019
f10bfc8
Fix the handling of with statements in Python 3 in _parse.py
asmeurer Apr 11, 2019
39d91bb
Replace sys.version_info checks with six.PY2 and six.PY3
asmeurer Apr 11, 2019
e72f059
Define Python 3 compatible comparisons on the Import class
asmeurer Apr 11, 2019
6ddfba0
Define Python 3 compatible comparisons using functools.total_ordering…
asmeurer Apr 11, 2019
e8c7ce1
total_ordering doesn't automatically define __ne__
asmeurer Apr 11, 2019
f96526d
Fix pipe() in test_cmdline.py to handle bytes/str in Python 3 correctly
asmeurer Apr 11, 2019
6c86c5c
Fix the mode for NamedTemporaryFile to not be bytes in tests/test_cmd…
asmeurer Apr 11, 2019
d764230
Fix missing __ne__ definitions in _importstmt.py
asmeurer Apr 11, 2019
0561103
Fix AST related Python 3 incompatibilities in autoimp.py
asmeurer Apr 11, 2019
d72d8f8
Fix bytecode access in Python 3
asmeurer Apr 11, 2019
396c35d
Fix opcode argument handling for Python 3
asmeurer Apr 12, 2019
5099114
Attributes in Python 3 use LOAD_METHOD instead of LOAD_ATTR
asmeurer Apr 12, 2019
fe5753d
Fix bytecode argument handling logic in Python 3
asmeurer Apr 12, 2019
0a566fc
Change func_name to __name__ in a test for Python 3 compatibility
asmeurer Apr 12, 2019
6469d54
Fix some tests to check for ModuleNotFoundError instead of ImportErro…
asmeurer Apr 12, 2019
0025900
Use mode='w+' with NamedTemporaryFile for Python 3 compatibility
asmeurer Apr 12, 2019
b55758e
Change func_name to __name__ in a doctest
asmeurer Apr 13, 2019
32c68bc
Start translating the tests in test_interactive.py to use bytes every…
asmeurer Apr 17, 2019
6a27b3f
Don't show the flaky test success output
asmeurer Apr 18, 2019
fdf73d4
Use BytesIO instead of StringIO for the output in test_interactive.py
asmeurer Apr 18, 2019
3b6d10f
Use bytes for more regular expressions in test_interactive.py
asmeurer Apr 18, 2019
723bfc3
Skip rlipython tests for IPython >= 7.0
asmeurer Apr 18, 2019
503469c
Use bytes for regular expressions in the matching code in test_intera…
asmeurer Apr 18, 2019
15c220d
Make it so the tests themselves don't have to use bytes
asmeurer Apr 18, 2019
b8b3880
Always disable colors in the IPython tests
asmeurer Apr 18, 2019
a390001
Disable prompt-toolkit matching bracket highlighting in the IPython t…
asmeurer Apr 22, 2019
3a9b5da
Change the print syntax in the test_interactive tests to be Python 3 …
asmeurer Apr 22, 2019
3c51986
Update test_interactive to handle the way prompt-toolkit 2.0 draws th…
asmeurer Apr 23, 2019
ed2d485
Delete CPR request warnings from the IPython output
asmeurer Apr 23, 2019
00cc09a
Don't require bytes input to parse_template
asmeurer Apr 23, 2019
7732595
Update ipython() to handle parse_template() taking a str instead of b…
asmeurer Apr 23, 2019
58d724f
Update parse_template and assert_match tests to use bytes
asmeurer Apr 23, 2019
5520131
Correctly handle the case when the cursor movement should use buffering
asmeurer Apr 23, 2019
0a89ac4
Work around a prompt-toolkit issue in test_interactive
asmeurer Apr 23, 2019
157ad95
Make some strings with invalid escapes raw strings
asmeurer Apr 23, 2019
a88ad93
Correctly handle prompt-toolkit 2.0 cursor movement with multiple lines
asmeurer Apr 24, 2019
3682e0f
Fix CSI Ps A handling in AnsiFilterDecoder
asmeurer Apr 24, 2019
1143a7d
Disable autoindent for IPython 7+
asmeurer Apr 24, 2019
b5fe657
Use readlinelike completion display with prompt-toolkit 2.0
asmeurer Apr 26, 2019
4f66b8c
Handle \n<move cursor right> escape codes in the ANSI decoder
asmeurer Apr 26, 2019
d8eceef
Fix some test_interactive output to be compatible with Python 3
asmeurer Apr 26, 2019
386c2e8
Fix test_cmdline.py tests to work with Python 3
asmeurer Apr 30, 2019
336875e
Make sure a test in test_interactive.py always uses exec, even in Pyt…
asmeurer Apr 30, 2019
bfabd7c
Fix shebang detection in binary files in _py.py in Python 3
asmeurer Apr 30, 2019
614416a
Fix an issue that lead *args and **kwargs to be seen as unused variab…
asmeurer Apr 30, 2019
9f23e09
Fix most of the tests in test_py.py to work with Python 3
asmeurer May 1, 2019
efb5e0a
Remove duplicate test test_unsafe_concat_1
asmeurer May 1, 2019
26281bc
Fix 'py print sys' test output for Python 3
asmeurer May 1, 2019
a908626
Fix the node visitor for Bytes nodes (Python 3)
asmeurer May 1, 2019
3fa85c0
Fix the ctypes py test for Python 3
asmeurer May 1, 2019
95d4495
Fix bytes test
asmeurer May 1, 2019
50abb5e
Fix test_ctypes_1 in Python 2
asmeurer May 2, 2019
70b2364
Fix test_imports2s.py tests for Python 3
asmeurer May 2, 2019
ac37bab
Ignore bytes and unicode literals in doctests
asmeurer May 3, 2019
d4d874a
Fix a string that uses an invalid escape sequence
asmeurer May 3, 2019
cd5130a
Fix some invalid escape sequences
asmeurer May 3, 2019
721f393
Test for invalid escape sequences in strings on Travis
asmeurer May 3, 2019
d10782f
Make deprecation warnings give errors in the tests
asmeurer May 3, 2019
fe34672
Fix deprecated use of inspect.getargspec in _livepatch.py in Python 3
asmeurer May 3, 2019
c0d9b55
Merge branch 'master' into python3
asmeurer May 3, 2019
977da87
Fix a doctest error in Python 3
asmeurer May 3, 2019
8123b2e
Fix some hasattrs to use Python 3 idioms
asmeurer May 3, 2019
a7f4837
Fix the remaining doctests to work with Python 3
asmeurer May 3, 2019
7e9604f
Move prompt-toolkit bug workaround replacements after the replacement…
asmeurer May 6, 2019
1b55a31
Fix the IPython input transformer for the latest version of IPython
asmeurer May 6, 2019
1d381b5
Allow the test_interactive tests to be written with bytes
asmeurer May 6, 2019
ae04311
Change the test_interactive functions for the base64 functions in Pyt…
asmeurer May 6, 2019
3839542
Fix the bytes replacement regex to handle the string 'b'
asmeurer May 7, 2019
4a909b9
Fix the test_interactive tests to work in Python 2 again
asmeurer May 7, 2019
60b57b9
Don't show any flaky test output
asmeurer May 7, 2019
5954258
Correctly buffer some cases in the ANSI decoder where output gets split
asmeurer May 7, 2019
f9d69dd
Correct a comment
asmeurer May 7, 2019
fd88db9
Handle ZeroDivisionError giving different error messages in Python 2 …
asmeurer May 7, 2019
9ce2bce
Fix some Python 2/3 issues in test_interactive
asmeurer May 7, 2019
8da3ff7
Work around an issue with the autocall arrow being printed twice in n…
asmeurer May 7, 2019
341f37f
Use the cleanup input transformers
asmeurer May 7, 2019
919ec5a
Use child.close() instead of child.kill() in test_interactive
asmeurer May 9, 2019
1f8cbb4
Remove unused import
asmeurer May 9, 2019
8a603bb
Fix Aspect to properly work with Python 3 "unbound" methods
asmeurer May 9, 2019
a4d5631
Better handling of "unbound" methods in the _util code in Python 3
asmeurer May 10, 2019
43c06a0
The debugger output in IPython still uses () after <module> in Python 3
asmeurer May 10, 2019
4ff3384
Add support for advising property methods
asmeurer May 10, 2019
bf6d8ad
Better error message
asmeurer May 10, 2019
cf5418a
Support IPython 6.0+ tab completions
asmeurer May 10, 2019
15d5c8f
The hook should not be a property in the first place
asmeurer May 10, 2019
c1a098b
Avoid advising completer.matchers more than once
asmeurer May 10, 2019
2ab41dd
Handle prompt-toolkit producing multiple "assert app._is_running" errors
asmeurer May 10, 2019
132a701
Handle another buffered output case in AnsiFilterDecoder
asmeurer May 10, 2019
6d301b1
Workaround an upstream IPython bug where input transformers get calle…
asmeurer May 10, 2019
5cd250e
Handle CPR request warnings from tab completion in AnsiFilterDecoder
asmeurer May 10, 2019
91b8238
Better prevention of multiple calls of the input transformer in IPyth…
asmeurer May 11, 2019
8057d82
Buffer the arg if it ends with escape
asmeurer May 13, 2019
d068444
Handle prompt-toolkit 2.0 clearing tab completions differently
asmeurer May 13, 2019
8bfc727
Handle the matching bracket highlighter not being disableable with py…
asmeurer May 13, 2019
a8e094c
Handle different NameError error message in Python 2 and 3
asmeurer May 13, 2019
1b51545
Handle different timeit output in the newer IPythons
asmeurer May 13, 2019
d7a598d
Fix NameError processing for Python 2/3
asmeurer May 13, 2019
2c7d712
Handle different import error messages in Python 2/3
asmeurer May 13, 2019
77240f0
Fix some minor Python 2/3 typos in the test_interactive tests
asmeurer May 13, 2019
d7a7f57
Make sure exitstr is always a bytes
asmeurer May 14, 2019
878d680
Handle different NameError output from the debugger in Python 2/3
asmeurer May 14, 2019
63631e2
Make a string with non-ASCII characters unicode
asmeurer May 14, 2019
bd396ea
xfail the Jupyter console tests with the latest IPython
asmeurer May 14, 2019
e80083b
Buffer any uncompleted escape sequence at the end of the input in Ans…
asmeurer May 15, 2019
6f516e5
Use the config file to disable come prompt-toolkit features
asmeurer May 15, 2019
bc0ec79
Handle some bytes/string issues in the Jupyter console testing
asmeurer May 15, 2019
e65a2cd
Add a note about xfail_jupyter_console
asmeurer May 15, 2019
874791e
Un-xfail some jupyter console tests that work
asmeurer May 15, 2019
9631215
Test the IPython tests with with PROMPT_TOOLKIT_NO_CPR=1
asmeurer May 15, 2019
d1726ff
Fix test_manual_install_exec_files_1
asmeurer May 15, 2019
31dfef3
Re-disable matching bracket highlighting for IPython >= 5
asmeurer May 15, 2019
77114b4
Fix a bytes-str issue
asmeurer May 15, 2019
1387cb1
Append to the config file, so we don't lose the existing config options
asmeurer May 15, 2019
195f608
Disable bracket highlighting in the jupyter console
asmeurer May 16, 2019
d545bb1
Only retry on timeout errors
asmeurer May 16, 2019
f5a798c
Remove some unnecessary matching bracket workarounds
asmeurer May 16, 2019
c18a819
Use append instead of duplicating the settings
asmeurer May 16, 2019
5162c08
Use the correct timeout exception
asmeurer May 16, 2019
ab615f9
See if upping the flaky max runs makes the tests pass on Travis
asmeurer May 16, 2019
725ccd0
Also retry on AssertionError
asmeurer May 16, 2019
e123b0e
Revert "See if upping the flaky max runs makes the tests pass on Travis"
asmeurer May 16, 2019
5a91f35
Install prompt-toolkit from git on Travis
asmeurer May 16, 2019
2d5a918
Only install prompt-toolkit from git in Python 3
asmeurer May 16, 2019
b106073
Test using my prompt-toolkit branch without the assert on Travis
asmeurer May 16, 2019
62458f9
Fix Travis syntax
asmeurer May 16, 2019
9d3eeec
We have to use -U to force pip to install it
asmeurer May 16, 2019
8df9b15
Fix a test for Python 3
asmeurer May 17, 2019
c5b4ed2
Fix usage of types.DictProxyType for Python 3
asmeurer May 17, 2019
9ff171d
Use ipkernel instead of jupyter_console in py console
asmeurer May 17, 2019
0c18fe8
Enable the jupyter console tests/test_interactive
asmeurer May 17, 2019
436776c
Install jupyter_console from my branch on Travis for now
asmeurer May 17, 2019
d953bb2
Fix synatx in .travis.yml
asmeurer May 17, 2019
558c084
Handle exceptions taking more than one argument
asmeurer May 17, 2019
afff20c
Make sure the input to ast.parse isn't unicode in Python 2
asmeurer May 17, 2019
eb5d666
Make sure unicode is imported in Python 3
asmeurer May 17, 2019
979a099
Handle Bytes wherever Str is allowed in _parse
asmeurer May 17, 2019
9bd9d73
Add __future__.print_function as a mandatory import
asmeurer May 17, 2019
c80795b
Run tidy-imports on lib/ and tests
asmeurer May 17, 2019
fe490b3
Fix the py command line examples to give Python 3 output
asmeurer May 17, 2019
e20e5b0
Properly handle "except ... as e" in autoimp in Python 3
asmeurer May 17, 2019
bcb9a7a
Fix support for Python 3 dictionaries with ** in autoimp
asmeurer May 17, 2019
4b42e25
Add autoimp tests for several Python 3-only syntax features
asmeurer May 17, 2019
4e1c800
Modify the starred function call test a bit, and add a Python 2-compa…
asmeurer May 17, 2019
e1ccb5d
Add support to autoimp for Python 3 keyword arguments in class defini…
asmeurer May 17, 2019
cab8b09
Add some tests for f-strings in autoimp
asmeurer May 17, 2019
50e315b
Add a test to make sure True, False, and None are handled correctly i…
asmeurer May 17, 2019
544cf73
Add a test for Python 3 matmul syntax
asmeurer May 17, 2019
0223330
Add a test for a variable assignment with an annotation
asmeurer May 17, 2019
37d403a
Use consistent naming for the tests
asmeurer May 17, 2019
9b4cece
Add an autoimp test for an async comprehension
asmeurer May 17, 2019
0bbe8f4
Add an autoimp test for async/await
asmeurer May 17, 2019
0d1d203
Remove some accidentally repeated comments
asmeurer May 17, 2019
0ad7b1d
Add an autoimp test for nested with statements
asmeurer May 17, 2019
98fcbaf
Add an autoimp test for yield from
asmeurer May 17, 2019
e4c9ca5
Make the async/await test test all the async/await node types
asmeurer May 17, 2019
5c7f65d
Revert "Add __future__.print_function as a mandatory import"
asmeurer May 17, 2019
5bfd84a
Revert print_function addition to tests/xrefs.py
asmeurer May 17, 2019
7c2cb99
Test removing the rerun filter
asmeurer May 17, 2019
b00d688
Fix _py doctest
asmeurer May 18, 2019
74b3771
Merge two __future__ imports together
asmeurer May 20, 2019
6499731
Remove long call from Python 2 compatibility code
asmeurer May 20, 2019
10fb5b2
Add a clarifying comment
asmeurer May 20, 2019
02d2a7d
Make __future__.print_function a mandatory import for pyflyby
asmeurer May 21, 2019
d0fc3a5
Fix str/bytes issue
asmeurer May 21, 2019
7994507
Run tidy-imports
asmeurer May 21, 2019
5cf1cb1
Update the docxref test
asmeurer May 21, 2019
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
3 changes: 3 additions & 0 deletions .pyflyby
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
#
# To regenerate this file, run: setup.py collect_imports

__mandatory_imports__ = [
'from __future__ import print_function',
]

import pyflyby
from pyflyby._autoimp import (auto_eval, auto_import,
Expand Down
27 changes: 20 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,32 @@ matrix:
dist: xenial
sudo: true

allow_failures:
- python: 3.7
dist: xenial
sudo: true

install:
- set -e
- pip install -U pip
- pip install -U "pexpect>=3.3" pyflakes pytest epydoc rlipython requests jupyter flaky
# Install prompt-toolkit from git until a release is made with
# PROMPT_TOOLKIT_NO_CPR environment variable support.
# Install jupyter_console from
# https://github.com/jupyter/jupyter_console/pull/187 until it is included
# in a release
- if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
pip install -U "pexpect>=3.3" pyflakes pytest epydoc rlipython requests jupyter flaky flake8;
else
pip install -U "pexpect>=3.3" pyflakes pytest rlipython requests jupyter flaky flake8;
pip install -U git+https://github.com/prompt-toolkit/[email protected];
pip install -U git+https://github.com/asmeurer/jupyter_console@display_completions;
fi
- pip list

script:
- set -e
- set -x
- shopt -s extglob globstar
# pyflakes all files except for known_imports/*, etc/*, and __init__.py,
# which are all unused imports. We use flake8 so we can use noqa if
# necessary.
- flake8 --exclude known_imports,etc,__init__.py --select=F
# Test for invalid escape sequences (will be syntax errors in a future
# Python version)
- python -We:invalid -m compileall -f -q lib/ etc/;
- export DEBUG_TEST_PYFLYBY=1
- pytest --doctest-modules lib tests
9 changes: 5 additions & 4 deletions bin/autoipython
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Or, you can manually add 'pyflyby.enable_auto_importer()' wherever you prefer.
# License: MIT http://opensource.org/licenses/MIT

from __future__ import absolute_import, division, with_statement
from __future__ import print_function

import sys

Expand All @@ -51,10 +52,10 @@ from pyflyby._interactive import (install_in_ipython_config_file,

def main(args):
if any(a in ["--help", "-help", "-h"] for a in args):
print maindoc()
print
print "----------------------------------------------------------------------"
print
print(maindoc())
print()
print("----------------------------------------------------------------------")
print()
start_ipython_with_autoimporter(["--help"])
return
if args and args[0] in ["--install", "-install", "install"]:
Expand Down
7 changes: 4 additions & 3 deletions bin/collect-exports
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Print the result to stdout.


from __future__ import absolute_import, division, with_statement
from __future__ import print_function

import sys

Expand Down Expand Up @@ -49,7 +50,7 @@ def main():
db = ImportDB.get_default(".")
known = db.known_imports.imports
args += sorted(set(
filter(None, [i.split.module_name for i in known])))
[_f for _f in [i.split.module_name for i in known] if _f]))
bad_module_names = []
for module_name in args:
module = ModuleHandle(module_name)
Expand All @@ -68,8 +69,8 @@ def main():
sys.stdout.write(imports.pretty_print(
allow_conflicts=True, params=options.params))
if bad_module_names:
print >>sys.stderr, "collect-exports: there were problems with: %s" % (
' '.join(bad_module_names))
print("collect-exports: there were problems with: %s" % (
' '.join(bad_module_names)), file=sys.stderr)
sys.exit(1)


Expand Down
3 changes: 2 additions & 1 deletion bin/find-import
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Prints how to import given name(s).
# License: MIT http://opensource.org/licenses/MIT

from __future__ import absolute_import, division, with_statement
from __future__ import print_function

from pyflyby._cmdline import parse_args, syntax
from pyflyby._importdb import ImportDB
Expand All @@ -30,7 +31,7 @@ def main():
logger.error("Can't find import for %r", arg)
else:
for imp in imports:
print imp.pretty_print(params=options.params),
print(imp.pretty_print(params=options.params), end=' ')
if errors:
raise SystemExit(1)

Expand Down
5 changes: 3 additions & 2 deletions bin/list-bad-xrefs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Similar to running C{epydoc -v}, but:
# License: MIT http://opensource.org/licenses/MIT

from __future__ import absolute_import, division, with_statement
from __future__ import print_function

from pyflyby._cmdline import parse_args, syntax
from pyflyby._docxref import find_bad_doc_cross_references
Expand All @@ -27,8 +28,8 @@ def main():
for rec in find_bad_doc_cross_references(args):
module, linenos, container_name, identifier = rec
for lineno in linenos or ["?"]:
print "%s:%s: undefined docstring cross-reference in %s: %s" % (
module.filename, lineno, container_name, identifier)
print("%s:%s: undefined docstring cross-reference in %s: %s" % (
module.filename, lineno, container_name, identifier))


if __name__ == '__main__':
Expand Down
12 changes: 12 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import re
import sys

from six import PY3

_already_ran_setup = False

def pytest_runtest_setup(item):
Expand All @@ -23,13 +25,23 @@ def pytest_runtest_setup(item):
_setup_logger()


def pytest_ignore_collect(path, config):
""" return True to prevent considering this path for collection.
This hook is consulted for all files and directories prior to calling
more specific hooks.
"""
if str(path).endswith('_docxref.py') and PY3:
return True

def pytest_report_header(config):
import IPython
print("IPython %s" % (IPython.__version__))
import pyflyby
dir = os.path.dirname(pyflyby.__file__)
print("pyflyby %s from %s" % (pyflyby.__version__, dir))

def pytest_cmdline_preparse(config, args):
args[:] = ["--no-success-flaky-report", "--no-flaky-report"] + args

def _setup_logger():
"""
Expand Down
3 changes: 2 additions & 1 deletion lib/python/pyflyby/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
# Copyright (C) 2011, 2012, 2013, 2014, 2015, 2018 Karl Chen.
# License: MIT http://opensource.org/licenses/MIT

from __future__ import absolute_import, division, with_statement
from __future__ import (absolute_import, division, print_function,
with_statement)

from pyflyby._autoimp import (auto_eval, auto_import,
find_missing_imports)
Expand Down
3 changes: 2 additions & 1 deletion lib/python/pyflyby/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
# Copyright (C) 2014, 2015 Karl Chen.
# License: MIT http://opensource.org/licenses/MIT

from __future__ import absolute_import, division, with_statement
from __future__ import (absolute_import, division, print_function,
with_statement)

if __name__ == "__main__":
from pyflyby._py import py_main
Expand Down
Loading