From b436a4488e58735c7cf91a9e03e4c7e61867f75a Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Wed, 23 Mar 2022 16:03:00 +0200 Subject: [PATCH 1/3] Drop testfixtures dependency The Python versions supported by this package all have `contextlib.redirect_stdout` --- flake8_isort.py | 24 ++++++++++-------------- setup.py | 1 - 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/flake8_isort.py b/flake8_isort.py index 8b5162b..d668de5 100644 --- a/flake8_isort.py +++ b/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' @@ -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', @@ -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), @@ -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 ] diff --git a/setup.py b/setup.py index 81115b9..40110bc 100644 --- a/setup.py +++ b/setup.py @@ -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'], From 2dcd52f441821802ae7c0663979fa3b4cddddbd5 Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Wed, 27 Apr 2022 10:38:13 +0300 Subject: [PATCH 2/3] CI: install toml if required --- .github/workflows/tests.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d34bd8b..aa654c2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -30,6 +30,10 @@ jobs: architecture: x64 - name: Install matrix dependencies run: pip install 'isort==${{ matrix.isort }}' 'flake8==${{ matrix.flake8 }}' + # isort 4.x requires `toml` to be able to read pyproject.toml, so install it... + - name: Install toml if required + run: pip install toml + if: matrix.isort == '4.3.21' - name: Install dependencies run: pip install .[test] - name: flake8 From f06b8ad564be2e37614f35bc43b7bacc31ef1d47 Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Wed, 27 Apr 2022 14:20:24 +0300 Subject: [PATCH 3/3] Update changelog --- CHANGES.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 59f439a..24fed82 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -6,7 +6,7 @@ Changelog 4.1.2 (unreleased) ------------------ -- Nothing changed yet. +- The package no longer depends on ``testfixtures``. 4.1.1 (2021-10-14)