mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-07 21:44:18 +00:00
automatic: pyupgrade --py36-plus
This commit is contained in:
parent
8cc3fc01e8
commit
358ae85120
51 changed files with 185 additions and 149 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
"""Tests for the BaseFormatter object."""
|
||||
import argparse
|
||||
from unittest import mock
|
||||
|
||||
import mock
|
||||
import pytest
|
||||
|
||||
from flake8 import style_guide
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
"""Tests for our debugging module."""
|
||||
import mock
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
|
||||
from flake8.main import debug
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
"""Tests for get_local_plugins."""
|
||||
import mock
|
||||
from unittest import mock
|
||||
|
||||
from flake8.options import config
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
"""Tests for flake8.plugins.manager.Plugin."""
|
||||
import argparse
|
||||
from unittest import mock
|
||||
|
||||
import mock
|
||||
import pytest
|
||||
|
||||
from flake8 import exceptions
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
"""Tests for flake8.plugins.manager.PluginTypeManager."""
|
||||
import mock
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
|
||||
from flake8 import exceptions
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue