Skip to content

Commit 5a42f5c

Browse files
authored
Merge pull request #113 from akx/no-testfixtures
Drop testfixtures dependency
2 parents c8072e0 + f06b8ad commit 5a42f5c

File tree

4 files changed

+15
-16
lines changed

4 files changed

+15
-16
lines changed

.github/workflows/tests.yml

+4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ jobs:
3030
architecture: x64
3131
- name: Install matrix dependencies
3232
run: pip install 'isort==${{ matrix.isort }}' 'flake8==${{ matrix.flake8 }}'
33+
# isort 4.x requires `toml` to be able to read pyproject.toml, so install it...
34+
- name: Install toml if required
35+
run: pip install toml
36+
if: matrix.isort == '4.3.21'
3337
- name: Install dependencies
3438
run: pip install .[test]
3539
- name: flake8

CHANGES.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Changelog
66
4.1.2 (unreleased)
77
------------------
88

9-
- Nothing changed yet.
9+
- The package no longer depends on ``testfixtures``.
1010

1111

1212
4.1.1 (2021-10-14)

flake8_isort.py

+10-14
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
# -*- coding: utf-8 -*-
22

3-
import isort
4-
3+
from contextlib import redirect_stdout
4+
from difflib import Differ
5+
from difflib import unified_diff
6+
from io import StringIO
7+
from pathlib import Path
58

6-
if hasattr(isort, 'api'): # isort 5
7-
from contextlib import redirect_stdout
8-
from difflib import unified_diff
9-
from io import StringIO
10-
from pathlib import Path
9+
import isort
10+
import warnings
1111

12-
import warnings
13-
else:
14-
from difflib import Differ
15-
from testfixtures import OutputCapture
1612

1713
__version__ = '4.1.2.dev0'
1814

@@ -46,7 +42,6 @@ def __init__(self, tree, filename, lines):
4642

4743
@classmethod
4844
def add_options(cls, parser):
49-
5045
parser.add_option(
5146
'--isort-show-traceback',
5247
action='store_true',
@@ -68,7 +63,8 @@ def run(self):
6863
file_path = self.filename
6964
else:
7065
file_path = None
71-
with OutputCapture() as buffer:
66+
buffer = StringIO()
67+
with redirect_stdout(buffer):
7268
sort_result = isort.SortImports(
7369
file_path=file_path,
7470
file_contents=''.join(self.lines),
@@ -129,7 +125,7 @@ def _format_isort_output(self, isort_buffer):
129125
valid_lines = ['']
130126
valid_lines += [
131127
line
132-
for line in isort_buffer.output.getvalue().splitlines()
128+
for line in isort_buffer.getvalue().splitlines()
133129
if line.strip().split(' ', 1)[0] not in filtering_out
134130
]
135131

setup.py

-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ def get_version(file="flake8_isort.py"):
5757
install_requires=[
5858
'flake8 >= 3.2.1, <5',
5959
'isort >= 4.3.5, <6',
60-
'testfixtures >= 6.8.0, <7',
6160
],
6261
extras_require={
6362
'test': ['pytest-cov'],

0 commit comments

Comments
 (0)