Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Replace flake8 with ruff #629

Merged
merged 2 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .flake8

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
- run:
pip install flake8 flake8-import-order sphinx rstcheck[sphinx] doc8
pip install ruff sphinx rstcheck[sphinx] doc8
- run: pip install .
- run: flake8 .
- run: ruff .
- run: doc8 $(git ls-files '*.rst')
- run: rstcheck --ignore-directives automodule $(git ls-files '*.rst')
- run: yamllint --strict $(git ls-files '*.yaml' '*.yml')
Expand Down
5 changes: 5 additions & 0 deletions .ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[lint]
extend-select = ["I"]

[lint.isort]
known-third-party = ["tests"]
2 changes: 1 addition & 1 deletion CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Pull Request Process

.. code:: bash

flake8 .
ruff .

If you added/modified documentation:

Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# 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('..'))
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ dynamic = ["version"]
[project.optional-dependencies]
dev = [
"doc8",
"flake8",
"flake8-import-order",
"rstcheck[sphinx]",
"ruff",
"sphinx",
]

Expand Down
1 change: 0 additions & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@

import locale


locale.setlocale(locale.LC_ALL, 'C')
2 changes: 1 addition & 1 deletion tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

import yaml

from yamllint.config import YamlLintConfig
from yamllint import linter
from yamllint.config import YamlLintConfig


class RuleTestCase(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion tests/rules/test_indentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

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


Expand Down
5 changes: 2 additions & 3 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from io import StringIO
import fcntl
import locale
import os
Expand All @@ -22,11 +21,11 @@
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:
Expand Down
5 changes: 2 additions & 3 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,17 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

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):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 1 addition & 2 deletions tests/test_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@
import os
import shutil
import subprocess
import tempfile
import sys
import tempfile
import unittest


PYTHON = sys.executable or 'python'


Expand Down
11 changes: 8 additions & 3 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
1 change: 0 additions & 1 deletion tests/test_spec_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

from tests.common import RuleTestCase


# This file checks examples from YAML 1.2 specification [1] against yamllint.
#
# [1]: http://www.yaml.org/spec/1.2/spec.html
Expand Down
3 changes: 1 addition & 2 deletions yamllint/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 1 addition & 2 deletions yamllint/linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import re
import io
import re

import yaml

from yamllint import parser


PROBLEM_LEVELS = {
0: None,
1: 'warning',
Expand Down
2 changes: 1 addition & 1 deletion yamllint/rules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
document_start,
empty_lines,
empty_values,
float_values,
hyphens,
indentation,
key_duplicates,
Expand All @@ -33,7 +34,6 @@
new_line_at_end_of_file,
new_lines,
octal_values,
float_values,
quoted_strings,
trailing_spaces,
truthy,
Expand Down
1 change: 0 additions & 1 deletion yamllint/rules/anchors.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@

from yamllint.linter import LintProblem


ID = 'anchors'
TYPE = 'token'
CONF = {'forbid-undeclared-aliases': bool,
Expand Down
1 change: 0 additions & 1 deletion yamllint/rules/braces.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@
from yamllint.linter import LintProblem
from yamllint.rules.common import spaces_after, spaces_before


ID = 'braces'
TYPE = 'token'
CONF = {'forbid': (bool, 'non-empty'),
Expand Down
1 change: 0 additions & 1 deletion yamllint/rules/brackets.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@
from yamllint.linter import LintProblem
from yamllint.rules.common import spaces_after, spaces_before


ID = 'brackets'
TYPE = 'token'
CONF = {'forbid': (bool, 'non-empty'),
Expand Down
1 change: 0 additions & 1 deletion yamllint/rules/colons.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@

from yamllint.rules.common import is_explicit_key, spaces_after, spaces_before


ID = 'colons'
TYPE = 'token'
CONF = {'max-spaces-before': int,
Expand Down
1 change: 0 additions & 1 deletion yamllint/rules/commas.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@
from yamllint.linter import LintProblem
from yamllint.rules.common import spaces_after, spaces_before


ID = 'commas'
TYPE = 'token'
CONF = {'max-spaces-before': int,
Expand Down
1 change: 0 additions & 1 deletion yamllint/rules/comments.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@

from yamllint.linter import LintProblem


ID = 'comments'
TYPE = 'comment'
CONF = {'require-starting-space': bool,
Expand Down
1 change: 0 additions & 1 deletion yamllint/rules/comments_indentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
from yamllint.linter import LintProblem
from yamllint.rules.common import get_line_indent


ID = 'comments-indentation'
TYPE = 'comment'

Expand Down
1 change: 0 additions & 1 deletion yamllint/rules/document_end.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@

from yamllint.linter import LintProblem


ID = 'document-end'
TYPE = 'token'
CONF = {'present': bool}
Expand Down
1 change: 0 additions & 1 deletion yamllint/rules/document_start.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@

from yamllint.linter import LintProblem


ID = 'document-start'
TYPE = 'token'
CONF = {'present': bool}
Expand Down
1 change: 0 additions & 1 deletion yamllint/rules/empty_lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@

from yamllint.linter import LintProblem


ID = 'empty-lines'
TYPE = 'line'
CONF = {'max': int,
Expand Down
1 change: 0 additions & 1 deletion yamllint/rules/empty_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@

from yamllint.linter import LintProblem


ID = 'empty-values'
TYPE = 'token'
CONF = {'forbid-in-block-mappings': bool,
Expand Down
1 change: 0 additions & 1 deletion yamllint/rules/float_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@

from yamllint.linter import LintProblem


ID = 'float-values'
TYPE = 'token'
CONF = {
Expand Down
1 change: 0 additions & 1 deletion yamllint/rules/hyphens.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@

from yamllint.rules.common import spaces_after


ID = 'hyphens'
TYPE = 'token'
CONF = {'max-spaces-after': int}
Expand Down
1 change: 0 additions & 1 deletion yamllint/rules/indentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@
from yamllint.linter import LintProblem
from yamllint.rules.common import get_real_end_line, is_explicit_key


ID = 'indentation'
TYPE = 'token'
CONF = {'spaces': (int, 'consistent'),
Expand Down
1 change: 0 additions & 1 deletion yamllint/rules/key_duplicates.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@

from yamllint.linter import LintProblem


ID = 'key-duplicates'
TYPE = 'token'
CONF = {'forbid-duplicated-merge-keys': bool}
Expand Down
1 change: 0 additions & 1 deletion yamllint/rules/key_ordering.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@

from yamllint.linter import LintProblem


ID = 'key-ordering'
TYPE = 'token'

Expand Down
1 change: 0 additions & 1 deletion yamllint/rules/line_length.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@

from yamllint.linter import LintProblem


ID = 'line-length'
TYPE = 'line'
CONF = {'max': int,
Expand Down
1 change: 0 additions & 1 deletion yamllint/rules/new_line_at_end_of_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

from yamllint.linter import LintProblem


ID = 'new-line-at-end-of-file'
TYPE = 'line'

Expand Down
1 change: 0 additions & 1 deletion yamllint/rules/new_lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@

from yamllint.linter import LintProblem


ID = 'new-lines'
TYPE = 'line'
CONF = {'type': ('unix', 'dos', 'platform')}
Expand Down
1 change: 0 additions & 1 deletion yamllint/rules/octal_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@

from yamllint.linter import LintProblem


ID = 'octal-values'
TYPE = 'token'
CONF = {'forbid-implicit-octal': bool,
Expand Down
1 change: 0 additions & 1 deletion yamllint/rules/trailing_spaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@

from yamllint.linter import LintProblem


ID = 'trailing-spaces'
TYPE = 'line'

Expand Down
1 change: 0 additions & 1 deletion yamllint/rules/truthy.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@

from yamllint.linter import LintProblem


TRUTHY = ['YES', 'Yes', 'yes',
'NO', 'No', 'no',
'TRUE', 'True', 'true',
Expand Down
Loading