automatic: pyupgrade --py36-plus

This commit is contained in:
Anthony Sottile 2021-03-29 17:43:42 -07:00
parent 8cc3fc01e8
commit 358ae85120
51 changed files with 185 additions and 149 deletions

View file

@ -1,3 +1,4 @@
from some.module.that.has.nested.sub.modules import ClassWithVeryVeryVeryVeryLongName # noqa: E501,F401
from some.module.that.has.nested.sub.modules import \
ClassWithVeryVeryVeryVeryLongName # noqa: E501,F401
# ClassWithVeryVeryVeryVeryLongName()

View file

@ -1,7 +1,7 @@
"""Module that is off sys.path by default, for testing local-plugin-paths."""
class ExtensionTestPlugin2(object):
class ExtensionTestPlugin2:
"""Extension test plugin in its own directory."""
name = 'ExtensionTestPlugin2'

View file

@ -1,5 +1,6 @@
"""Integration tests for the checker submodule."""
import mock
from unittest import mock
import pytest
from flake8 import checker
@ -20,7 +21,7 @@ EXPECTED_RESULT_PHYSICAL_LINE = (
)
class PluginClass(object):
class PluginClass:
"""Simple file plugin class yielding the expected report."""
name = 'test'

View file

@ -1,8 +1,8 @@
"""Integration tests for the main entrypoint of flake8."""
import json
import os
from unittest import mock
import mock
import pytest
from flake8 import utils
@ -280,13 +280,13 @@ def test_obtaining_args_from_sys_argv_when_not_explicity_provided(capsys):
def test_cli_config_option_respected(tmp_path):
"""Test --config is used."""
config = tmp_path / "flake8.ini"
config.write_text(u"""\
config.write_text("""\
[flake8]
ignore = F401
""")
py_file = tmp_path / "t.py"
py_file.write_text(u"import os\n")
py_file.write_text("import os\n")
_call_main(["--config", str(config), str(py_file)])
@ -294,13 +294,13 @@ ignore = F401
def test_cli_isolated_overrides_config_option(tmp_path):
"""Test --isolated overrides --config."""
config = tmp_path / "flake8.ini"
config.write_text(u"""\
config.write_text("""\
[flake8]
ignore = F401
""")
py_file = tmp_path / "t.py"
py_file.write_text(u"import os\n")
py_file.write_text("import os\n")
_call_main(["--isolated", "--config", str(config), str(py_file)], retv=1)

View file

@ -1,12 +1,11 @@
"""Integration tests for plugin loading."""
from flake8.main import application
LOCAL_PLUGIN_CONFIG = 'tests/fixtures/config_files/local-plugin.ini'
LOCAL_PLUGIN_PATH_CONFIG = 'tests/fixtures/config_files/local-plugin-path.ini'
class ExtensionTestPlugin(object):
class ExtensionTestPlugin:
"""Extension test plugin."""
name = 'ExtensionTestPlugin'
@ -24,7 +23,7 @@ class ExtensionTestPlugin(object):
parser.add_option('--anopt')
class ReportTestPlugin(object):
class ReportTestPlugin:
"""Report test plugin."""
name = 'ReportTestPlugin'

View file

@ -1,8 +1,8 @@
"""Tests for the Application class."""
import argparse
import sys
from unittest import mock
import mock
import pytest
from flake8.main import application as app

View file

@ -1,7 +1,7 @@
"""Tests for the BaseFormatter object."""
import argparse
from unittest import mock
import mock
import pytest
from flake8 import style_guide

View file

@ -1,7 +1,7 @@
"""Tests for the Manager object for FileCheckers."""
import errno
from unittest import mock
import mock
import pytest
from flake8 import checker

View file

@ -1,9 +1,8 @@
# -*- coding: utf-8 -*-
"""Tests for the ConfigFileFinder."""
import configparser
import os
from unittest import mock
import mock
import pytest
from flake8.options import config

View file

@ -1,5 +1,6 @@
"""Tests for our debugging module."""
import mock
from unittest import mock
import pytest
from flake8.main import debug

View file

@ -1,5 +1,6 @@
"""Unit tests for the FileChecker class."""
import mock
from unittest import mock
import pytest
import flake8
@ -50,7 +51,7 @@ def test_nonexistent_file():
def test_raises_exception_on_failed_plugin(tmp_path, default_options):
"""Checks that a failing plugin results in PluginExecutionFailed."""
foobar = tmp_path / 'foobar.py'
foobar.write_text(u"I exist!") # Create temp file
foobar.write_text("I exist!") # Create temp file
plugin = {
"name": "failure",
"plugin_name": "failure", # Both are necessary

View file

@ -1,8 +1,8 @@
"""Tests for the FileProcessor class."""
import ast
import tokenize
from unittest import mock
import mock
import pytest
from flake8 import processor
@ -46,7 +46,7 @@ def test_read_lines_unknown_encoding(tmpdir, default_options):
@pytest.mark.parametrize('first_line', [
'\xEF\xBB\xBF"""Module docstring."""\n',
u'\uFEFF"""Module docstring."""\n',
'\uFEFF"""Module docstring."""\n',
])
def test_strip_utf_bom(first_line, default_options):
r"""Verify that we strip '\xEF\xBB\xBF' from the first line."""
@ -58,7 +58,7 @@ def test_strip_utf_bom(first_line, default_options):
@pytest.mark.parametrize('lines, expected', [
(['\xEF\xBB\xBF"""Module docstring."""\n'], False),
([u'\uFEFF"""Module docstring."""\n'], False),
(['\uFEFF"""Module docstring."""\n'], False),
(['#!/usr/bin/python', '# flake8 is great', 'a = 1'], False),
(['#!/usr/bin/python', '# flake8: noqa', 'a = 1'], True),
(['#!/usr/bin/python', '# flake8:noqa', 'a = 1'], True),
@ -130,7 +130,7 @@ def test_noqa_line_for(default_options):
])
for i in range(1, 4):
assert file_processor.noqa_line_for(i) == 'Line {}\n'.format(i)
assert file_processor.noqa_line_for(i) == f'Line {i}\n'
def test_noqa_line_for_continuation(default_options):
@ -182,7 +182,7 @@ def test_next_line(default_options):
])
for i in range(1, 4):
assert file_processor.next_line() == 'Line {}'.format(i)
assert file_processor.next_line() == f'Line {i}'
assert file_processor.line_number == i

View file

@ -1,5 +1,5 @@
"""Tests for get_local_plugins."""
import mock
from unittest import mock
from flake8.options import config

View file

@ -1,8 +1,8 @@
"""Tests for Flake8's legacy API."""
import argparse
import os.path
from unittest import mock
import mock
import pytest
from flake8.api import legacy as api

View file

@ -1,7 +1,7 @@
"""Unit tests for flake8.options.config.MergedConfigParser."""
import os
from unittest import mock
import mock
import pytest
from flake8.options import config

View file

@ -1,7 +1,7 @@
"""Unit tests for flake8.options.manager.Option."""
import functools
from unittest import mock
import mock
import pytest
from flake8.options import manager

View file

@ -1,8 +1,8 @@
"""Unit tests for flake.options.manager.OptionManager."""
import argparse
import os
from unittest import mock
import mock
import pytest
from flake8 import utils

View file

@ -1,7 +1,7 @@
"""Tests for flake8.plugins.manager.Plugin."""
import argparse
from unittest import mock
import mock
import pytest
from flake8 import exceptions

View file

@ -1,5 +1,5 @@
"""Tests for flake8.plugins.manager.PluginManager."""
import mock
from unittest import mock
from flake8._compat import importlib_metadata
from flake8.plugins import manager

View file

@ -1,5 +1,6 @@
"""Tests for flake8.plugins.manager.PluginTypeManager."""
import mock
from unittest import mock
import pytest
from flake8 import exceptions

View file

@ -111,8 +111,8 @@ def test_statistic_for_retrieves_more_than_one_value():
"""Show this works for more than a couple statistic values."""
aggregator = stats.Statistics()
for i in range(50):
aggregator.record(make_error(code='E1{:02d}'.format(i)))
aggregator.record(make_error(code='W2{:02d}'.format(i)))
aggregator.record(make_error(code=f'E1{i:02d}'))
aggregator.record(make_error(code=f'W2{i:02d}'))
statistics = list(aggregator.statistics_for('E'))
assert len(statistics) == 50

View file

@ -1,7 +1,7 @@
"""Tests for the flake8.style_guide.StyleGuide class."""
import argparse
from unittest import mock
import mock
import pytest
from flake8 import statistics

View file

@ -3,8 +3,8 @@ import io
import logging
import os
import sys
from unittest import mock
import mock
import pytest
from flake8 import exceptions
@ -242,7 +242,7 @@ def test_filenames_from_exclude_doesnt_exclude_directory_names(tmpdir):
def test_parameters_for_class_plugin():
"""Verify that we can retrieve the parameters for a class plugin."""
class FakeCheck(object):
class FakeCheck:
def __init__(self, tree):
raise NotImplementedError
@ -268,7 +268,7 @@ def test_parameters_for_function_plugin():
def read_diff_file(filename):
"""Read the diff file in its entirety."""
with open(filename, 'r') as fd:
with open(filename) as fd:
content = fd.read()
return content

View file

@ -1,5 +1,6 @@
"""Tests for the flake8.style_guide.Violation class."""
import mock
from unittest import mock
import pytest
from flake8 import style_guide