Skip to content

Commit 1273645

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 935a7ba commit 1273645

9 files changed

+29
-24
lines changed

modernize/fixes/fix_itertools_imports_six.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
""" Fixer for imports of itertools.(imap|ifilter|izip|ifilterfalse) """
1+
"""Fixer for imports of itertools.(imap|ifilter|izip|ifilterfalse)"""
22

33
from __future__ import generator_stop
44

modernize/fixes/fix_itertools_six.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
""" Fixer for itertools.(imap|ifilter|izip) -->
2-
(six.moves.map|six.moves.filter|six.moves.zip) and
3-
itertools.ifilterfalse --> six.moves.filterfalse (bugs 2360-2363)
4-
imports from itertools are fixed in fix_itertools_imports_six.py
5-
If itertools is imported as something else (ie: import itertools as it;
6-
it.izip(spam, eggs)) method calls will not get fixed.
7-
"""
1+
"""Fixer for itertools.(imap|ifilter|izip) -->
2+
(six.moves.map|six.moves.filter|six.moves.zip) and
3+
itertools.ifilterfalse --> six.moves.filterfalse (bugs 2360-2363)
4+
imports from itertools are fixed in fix_itertools_imports_six.py
5+
If itertools is imported as something else (ie: import itertools as it;
6+
it.izip(spam, eggs)) method calls will not get fixed.
7+
"""
8+
89
# This is a derived work of Lib/lib2to3/fixes/fix_itertools_import.py. That file
910
# is under the copyright of the Python Software Foundation and licensed
1011
# under the Python Software Foundation License 2.

modernize/fixes/fix_metaclass.py

+11-10
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
"""Fixer for __metaclass__ = X -> (six.with_metaclass(X)) methods.
22
3-
The various forms of classdef (inherits nothing, inherits once, inherits
4-
many) don't parse the same in the CST, so we look at ALL classes for
5-
a __metaclass__ and if we find one normalize the inherits to all be
6-
an arglist.
3+
The various forms of classdef (inherits nothing, inherits once, inherits
4+
many) don't parse the same in the CST, so we look at ALL classes for
5+
a __metaclass__ and if we find one normalize the inherits to all be
6+
an arglist.
77
8-
For one-liner classes ('class X: pass') there is no indent/dedent so
9-
we normalize those into having a suite.
8+
For one-liner classes ('class X: pass') there is no indent/dedent so
9+
we normalize those into having a suite.
1010
11-
Moving the __metaclass__ into the classdef can also cause the class
12-
body to be empty so there is some special casing for that as well.
11+
Moving the __metaclass__ into the classdef can also cause the class
12+
body to be empty so there is some special casing for that as well.
1313
14-
This fixer also tries very hard to keep original indenting and spacing
15-
in all those corner cases.
14+
This fixer also tries very hard to keep original indenting and spacing
15+
in all those corner cases.
1616
"""
17+
1718
# This is a derived work of Lib/lib2to3/fixes/fix_metaclass.py. That file
1819
# is under the copyright of the Python Software Foundation and licensed
1920
# under the Python Software Foundation License 2.

modernize/fixes/fix_raise.py

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
any client code would have to be changed as well, we don't automate
1818
this.
1919
"""
20+
2021
# Author: Collin Winter, Armin Ronacher
2122
from __future__ import generator_stop
2223

modernize/fixes/fix_raise_six.py

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
raise E, V, T -> six.reraise(E, V, T)
44
55
"""
6+
67
# Author : Markus Unterwaditzer
78
from __future__ import generator_stop
89

modernize/fixes/fix_urllib_six.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
"""Fix changes imports of urllib which are now incompatible.
2-
This is a copy of Lib/lib2to3/fixes/fix_urllib.py, but modified to point to the
3-
six.moves locations for new libraries instead of the Python 3 locations.
2+
This is a copy of Lib/lib2to3/fixes/fix_urllib.py, but modified to point to the
3+
six.moves locations for new libraries instead of the Python 3 locations.
44
"""
5+
56
# This is a derived work of Lib/lib2to3/fixes/fix_urllib.py. That file
67
# is under the copyright of the Python Software Foundation and licensed
78
# under the Python Software Foundation License 2.

tests/test_fix_imports_six.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import unittest
55

66
try:
7-
from six.moves import tkinter
7+
import tkinter
88
except ImportError:
99
tkinter = None
1010

tests/test_future_behaviour.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def _check_on_input(file_content, extra_flags=[]):
6666
try:
6767
tmpdirname = tempfile.mkdtemp()
6868
test_input_name = os.path.join(tmpdirname, "input.py")
69-
with open(test_input_name, "wt") as input:
69+
with open(test_input_name, "w") as input:
7070
input.write(file_content)
7171
modernize_main(extra_flags + ["-w", test_input_name])
7272
_check_for_multiple_futures(test_input_name, file_content)
@@ -94,7 +94,7 @@ def test_two_files_on_single_run():
9494
os.path.join(tmpdirname, f"input_{idx}.py") for idx in range(0, 3)
9595
]
9696
for input_name in input_names:
97-
with open(input_name, "wt") as input:
97+
with open(input_name, "w") as input:
9898
input.write(TWO_PRINTS_CONTENT)
9999
modernize_main(["-w"] + input_names)
100100
for input_name in input_names:

tests/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def check_on_input(
2323
tmpdirname = tempfile.mkdtemp()
2424
try:
2525
test_input_name = os.path.join(tmpdirname, "input.py")
26-
with open(test_input_name, "wt") as input_file:
26+
with open(test_input_name, "w") as input_file:
2727
input_file.write(input_content)
2828

2929
def _check(this_input_content, which_check, check_return_code=True):

0 commit comments

Comments
 (0)