From f389cd43ae528779ae7c59cf6f6a6eb89ad444dc Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Thu, 4 Jan 2024 18:23:10 +0100 Subject: [PATCH] style: Apply new isort (I) rules to existing code --- docs/conf.py | 3 ++- setup.py | 1 + tests/common.py | 2 +- tests/rules/test_indentation.py | 3 +-- tests/rules/test_quoted_strings.py | 1 - tests/test_cli.py | 6 ++---- tests/test_config.py | 6 ++---- tests/test_linter.py | 2 +- tests/test_module.py | 2 +- tests/test_parser.py | 11 ++++++++--- yamllint/__main__.py | 1 + yamllint/cli.py | 3 +-- yamllint/linter.py | 2 +- yamllint/rules/__init__.py | 3 ++- yamllint/rules/quoted_strings.py | 1 + 15 files changed, 25 insertions(+), 22 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 2c40177c..1e5a87de 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,10 +1,11 @@ # yamllint documentation build configuration file, created by # sphinx-quickstart on Thu Jan 21 21:18:52 2016. -import sys import os +import sys from unittest.mock import MagicMock + sys.path.insert(0, os.path.abspath('..')) from yamllint import __copyright__, APP_NAME, APP_VERSION # noqa diff --git a/setup.py b/setup.py index ca785969..a934a905 100644 --- a/setup.py +++ b/setup.py @@ -15,6 +15,7 @@ from setuptools import setup + # This is only kept for backward-compatibility with older versions that don't # support new packaging standards (e.g. PEP 517 or PEP 660): setup() diff --git a/tests/common.py b/tests/common.py index 640be53b..1aef9e62 100644 --- a/tests/common.py +++ b/tests/common.py @@ -21,8 +21,8 @@ import yaml -from yamllint.config import YamlLintConfig from yamllint import linter +from yamllint.config import YamlLintConfig class RuleTestCase(unittest.TestCase): diff --git a/tests/rules/test_indentation.py b/tests/rules/test_indentation.py index ad1aeaff..e18b06e6 100644 --- a/tests/rules/test_indentation.py +++ b/tests/rules/test_indentation.py @@ -14,8 +14,7 @@ # along with this program. If not, see . from tests.common import RuleTestCase - -from yamllint.parser import token_or_comment_generator, Comment +from yamllint.parser import Comment, token_or_comment_generator from yamllint.rules.indentation import check diff --git a/tests/rules/test_quoted_strings.py b/tests/rules/test_quoted_strings.py index 1bcb6f8f..c83d3952 100644 --- a/tests/rules/test_quoted_strings.py +++ b/tests/rules/test_quoted_strings.py @@ -14,7 +14,6 @@ # along with this program. If not, see . from tests.common import RuleTestCase - from yamllint import config diff --git a/tests/test_cli.py b/tests/test_cli.py index f8493fe2..ea148aa3 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -13,7 +13,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -from io import StringIO import fcntl import locale import os @@ -22,11 +21,10 @@ import sys import tempfile import unittest +from io import StringIO from tests.common import build_temp_workspace, temp_workspace - -from yamllint import cli -from yamllint import config +from yamllint import cli, config class RunContext: diff --git a/tests/test_config.py b/tests/test_config.py index 13d7ab3b..0c2a2e9a 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -13,18 +13,16 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -from io import StringIO import os import shutil import sys import tempfile import unittest +from io import StringIO from tests.common import build_temp_workspace - +from yamllint import cli, config from yamllint.config import YamlLintConfigError -from yamllint import cli -from yamllint import config class SimpleConfigTestCase(unittest.TestCase): diff --git a/tests/test_linter.py b/tests/test_linter.py index 9855120b..ea509d8a 100644 --- a/tests/test_linter.py +++ b/tests/test_linter.py @@ -16,8 +16,8 @@ import io import unittest -from yamllint.config import YamlLintConfig from yamllint import linter +from yamllint.config import YamlLintConfig class LinterTestCase(unittest.TestCase): diff --git a/tests/test_module.py b/tests/test_module.py index 299e153d..2c2831a4 100644 --- a/tests/test_module.py +++ b/tests/test_module.py @@ -16,8 +16,8 @@ import os import shutil import subprocess -import tempfile import sys +import tempfile import unittest diff --git a/tests/test_parser.py b/tests/test_parser.py index dbeb36b4..c2b598ac 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -17,9 +17,14 @@ import yaml -from yamllint.parser import (line_generator, token_or_comment_generator, - token_or_comment_or_line_generator, - Line, Token, Comment) +from yamllint.parser import ( + Comment, + Line, + Token, + line_generator, + token_or_comment_generator, + token_or_comment_or_line_generator, +) class ParserTestCase(unittest.TestCase): diff --git a/yamllint/__main__.py b/yamllint/__main__.py index bc16534e..868bf297 100644 --- a/yamllint/__main__.py +++ b/yamllint/__main__.py @@ -1,4 +1,5 @@ from yamllint.cli import run + if __name__ == '__main__': run() diff --git a/yamllint/cli.py b/yamllint/cli.py index dadce781..1050d95d 100644 --- a/yamllint/cli.py +++ b/yamllint/cli.py @@ -19,8 +19,7 @@ import platform import sys -from yamllint import APP_DESCRIPTION, APP_NAME, APP_VERSION -from yamllint import linter +from yamllint import APP_DESCRIPTION, APP_NAME, APP_VERSION, linter from yamllint.config import YamlLintConfig, YamlLintConfigError from yamllint.linter import PROBLEM_LEVELS diff --git a/yamllint/linter.py b/yamllint/linter.py index 0de1f716..c0c0e5b7 100644 --- a/yamllint/linter.py +++ b/yamllint/linter.py @@ -13,8 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import re import io +import re import yaml diff --git a/yamllint/rules/__init__.py b/yamllint/rules/__init__.py index 606b37a4..fa6e8880 100644 --- a/yamllint/rules/__init__.py +++ b/yamllint/rules/__init__.py @@ -25,6 +25,7 @@ document_start, empty_lines, empty_values, + float_values, hyphens, indentation, key_duplicates, @@ -33,12 +34,12 @@ new_line_at_end_of_file, new_lines, octal_values, - float_values, quoted_strings, trailing_spaces, truthy, ) + _RULES = { anchors.ID: anchors, braces.ID: braces, diff --git a/yamllint/rules/quoted_strings.py b/yamllint/rules/quoted_strings.py index 5bfbd7a7..97f2c2a1 100644 --- a/yamllint/rules/quoted_strings.py +++ b/yamllint/rules/quoted_strings.py @@ -159,6 +159,7 @@ from yamllint.linter import LintProblem + ID = 'quoted-strings' TYPE = 'token' CONF = {'quote-type': ('any', 'single', 'double'),