Skip to content

Commit

Permalink
Drop testfixtures dependency
Browse files Browse the repository at this point in the history
The Python versions supported by this package all have `contextlib.redirect_stdout`
  • Loading branch information
akx committed Mar 23, 2022
1 parent c8072e0 commit 1857cd9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
24 changes: 10 additions & 14 deletions flake8_isort.py
@@ -1,18 +1,14 @@
# -*- coding: utf-8 -*-

import isort

from contextlib import redirect_stdout
from difflib import Differ
from difflib import unified_diff
from io import StringIO
from pathlib import Path

if hasattr(isort, 'api'): # isort 5
from contextlib import redirect_stdout
from difflib import unified_diff
from io import StringIO
from pathlib import Path
import isort
import warnings

import warnings
else:
from difflib import Differ
from testfixtures import OutputCapture

__version__ = '4.1.2.dev0'

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

@classmethod
def add_options(cls, parser):

parser.add_option(
'--isort-show-traceback',
action='store_true',
Expand All @@ -68,7 +63,8 @@ def run(self):
file_path = self.filename
else:
file_path = None
with OutputCapture() as buffer:
buffer = StringIO()
with redirect_stdout(buffer):
sort_result = isort.SortImports(
file_path=file_path,
file_contents=''.join(self.lines),
Expand Down Expand Up @@ -129,7 +125,7 @@ def _format_isort_output(self, isort_buffer):
valid_lines = ['']
valid_lines += [
line
for line in isort_buffer.output.getvalue().splitlines()
for line in isort_buffer.getvalue().splitlines()
if line.strip().split(' ', 1)[0] not in filtering_out
]

Expand Down
1 change: 0 additions & 1 deletion setup.py
Expand Up @@ -57,7 +57,6 @@ def get_version(file="flake8_isort.py"):
install_requires=[
'flake8 >= 3.2.1, <5',
'isort >= 4.3.5, <6',
'testfixtures >= 6.8.0, <7',
],
extras_require={
'test': ['pytest-cov'],
Expand Down

0 comments on commit 1857cd9

Please sign in to comment.