From 8d35a12d2714d93e541f28f51cd4cf94d47139b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Schoentgen?= Date: Tue, 1 Jun 2021 14:46:58 +0200 Subject: [PATCH] Fix several issues found with flake8 (#1081) --- httpie/cli/definition.py | 2 +- httpie/config.py | 1 - setup.cfg | 10 ++++++++-- setup.py | 2 +- tests/test_docs.py | 4 ++-- tests/test_httpie.py | 2 +- tests/test_output.py | 1 - tests/test_sessions.py | 2 +- tests/test_windows.py | 3 --- tests/utils/matching/test_matching.py | 8 ++++---- 10 files changed, 18 insertions(+), 17 deletions(-) diff --git a/httpie/cli/definition.py b/httpie/cli/definition.py index e0a53b27..28ca35ea 100644 --- a/httpie/cli/definition.py +++ b/httpie/cli/definition.py @@ -709,7 +709,7 @@ ssl.add_argument( ssl.add_argument( '--ssl', dest='ssl_version', - choices=list(sorted(AVAILABLE_SSL_VERSION_ARG_MAPPING.keys())), + choices=sorted(AVAILABLE_SSL_VERSION_ARG_MAPPING.keys()), help=''' The desired protocol version to use. This will default to SSL v2.3 which will negotiate the highest protocol that both diff --git a/httpie/config.py b/httpie/config.py index 5187da7e..ec4ad301 100644 --- a/httpie/config.py +++ b/httpie/config.py @@ -1,4 +1,3 @@ -import errno import json import os from pathlib import Path diff --git a/setup.cfg b/setup.cfg index 5640d04f..8301c1db 100644 --- a/setup.cfg +++ b/setup.cfg @@ -17,7 +17,13 @@ addopts = --tb=native --doctest-modules exclude = .git,.idea,__pycache__,build,dist,.pytest_cache,*.egg-info # -# E241 - multiple spaces after ',' # E501 - line too long # W503 - line break before binary operator -ignore = E241,E501,W503 +ignore = E501,W503 + + +[flake8] +# +# E501 - line too long +# W503 - line break before binary operator +ignore = E501,W503 diff --git a/setup.py b/setup.py index ca253fb8..9058c281 100644 --- a/setup.py +++ b/setup.py @@ -59,7 +59,7 @@ if 'bdist_wheel' not in sys.argv: # bdist_wheel extras_require = { - 'test': tests_require, + 'test': tests_require, # https://wheel.readthedocs.io/en/latest/#defining-conditional-dependencies ':sys_platform == "win32"': install_requires_win_only, } diff --git a/tests/test_docs.py b/tests/test_docs.py index b39d87c8..480fcdef 100644 --- a/tests/test_docs.py +++ b/tests/test_docs.py @@ -18,7 +18,7 @@ SOURCE_DIRECTORIES = [ def has_docutils(): try: # noinspection PyUnresolvedReferences,PyPackageRequirements - import docutils + import docutils # noqa return True except ImportError: return False @@ -35,7 +35,7 @@ def rst_filenames(): os.chdir(cwd) -filenames = list(sorted(rst_filenames())) +filenames = sorted(rst_filenames()) assert filenames diff --git a/tests/test_httpie.py b/tests/test_httpie.py index 42adbb50..7df4d478 100644 --- a/tests/test_httpie.py +++ b/tests/test_httpie.py @@ -130,7 +130,7 @@ def test_form_POST_file_redirected_stdin(httpbin): """ - with open(FILE_PATH) as f: + with open(FILE_PATH): r = http( '--form', 'POST', diff --git a/tests/test_output.py b/tests/test_output.py index a9edbf4c..825d59a8 100644 --- a/tests/test_output.py +++ b/tests/test_output.py @@ -4,7 +4,6 @@ from unittest import mock import json import os -import tempfile import io from urllib.request import urlopen diff --git a/tests/test_sessions.py b/tests/test_sessions.py index eaa923ef..8bd4d479 100644 --- a/tests/test_sessions.py +++ b/tests/test_sessions.py @@ -479,7 +479,7 @@ class TestCookieStorage(CookieTestBase): 2. command line arg 3. cookie already stored in session file """ - r = http( + http( '--session', str(self.session_path), httpbin.url + set_cookie, 'Cookie:' + cli_cookie, diff --git a/tests/test_windows.py b/tests/test_windows.py index 9354cb83..b30c7a50 100644 --- a/tests/test_windows.py +++ b/tests/test_windows.py @@ -1,6 +1,3 @@ -import os -import tempfile - import pytest from httpie.context import Environment diff --git a/tests/utils/matching/test_matching.py b/tests/utils/matching/test_matching.py index e74e126d..649884aa 100644 --- a/tests/utils/matching/test_matching.py +++ b/tests/utils/matching/test_matching.py @@ -69,19 +69,19 @@ def test_assert_output_matches_body_and_separator(): def test_assert_output_matches_body_r(): - assert_output_matches(f'AAA\r', [Expect.BODY]) + assert_output_matches('AAA\r', [Expect.BODY]) def test_assert_output_matches_body_n(): - assert_output_matches(f'AAA\n', [Expect.BODY]) + assert_output_matches('AAA\n', [Expect.BODY]) def test_assert_output_matches_body_r_body(): - assert_output_matches(f'AAA\rBBB', [Expect.BODY]) + assert_output_matches('AAA\rBBB', [Expect.BODY]) def test_assert_output_matches_body_n_body(): - assert_output_matches(f'AAA\nBBB', [Expect.BODY]) + assert_output_matches('AAA\nBBB', [Expect.BODY]) def test_assert_output_matches_headers_and_body():