Skip to content

Commit

Permalink
Enable ruff linter (#3276)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
ssbarnea and pre-commit-ci[bot] authored Apr 12, 2023
1 parent 502ea61 commit e221dd7
Show file tree
Hide file tree
Showing 14 changed files with 19 additions and 15 deletions.
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ repos:
files: \.(yaml|yml)$
types: [file, yaml]
entry: yamllint --strict
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.0.261"
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
Expand Down
1 change: 1 addition & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"recommendations": [
"Tyriar.sort-lines",
"charliermarsh.ruff",
"esbenp.prettier-vscode",
"hbenl.vscode-test-explorer",
"ms-python.isort",
Expand Down
8 changes: 8 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,14 @@ python_files = [
xfail_strict = true
markers = ["eco: Tests effects on a set of 3rd party ansible repositories"]

[tool.ruff]
# select = ["ALL"]
ignore = [
"E501", # we use black

]
target-version = "py39"

[tool.setuptools.dynamic]
optional-dependencies.docs = { file = [".config/requirements-docs.txt"] }
optional-dependencies.test = { file = [".config/requirements-test.txt"] }
Expand Down
2 changes: 1 addition & 1 deletion src/ansiblelint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"""Main ansible-lint package."""
from __future__ import annotations

import ansiblelint._vendor
import ansiblelint._vendor # noqa: F401
from ansiblelint.version import __version__

# make vendored top-level modules accessible EARLY
Expand Down
1 change: 0 additions & 1 deletion src/ansiblelint/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

if TYPE_CHECKING:
from argparse import Namespace
from typing import Dict, Set # pylint: disable=ungrouped-imports

from ansiblelint._internal.rules import BaseRule
from ansiblelint.file_utils import Lintable
Expand Down
2 changes: 1 addition & 1 deletion src/ansiblelint/formatters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import json
import os
from pathlib import Path
from typing import TYPE_CHECKING, Any, Dict, Generic, List, Tuple, TypeVar, Union
from typing import TYPE_CHECKING, Any, Generic, TypeVar

import rich

Expand Down
2 changes: 0 additions & 2 deletions src/ansiblelint/rules/meta_incorrect.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
from ansiblelint.rules import AnsibleLintRule

if TYPE_CHECKING:
from typing import Any

from ansiblelint.errors import MatchError
from ansiblelint.file_utils import Lintable

Expand Down
2 changes: 0 additions & 2 deletions src/ansiblelint/rules/meta_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@


if TYPE_CHECKING:
from typing import Any

from ansiblelint.errors import MatchError
from ansiblelint.file_utils import Lintable

Expand Down
2 changes: 0 additions & 2 deletions src/ansiblelint/rules/sanity.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@


if TYPE_CHECKING:
from typing import Any

from ansiblelint.errors import MatchError
from ansiblelint.file_utils import Lintable

Expand Down
1 change: 0 additions & 1 deletion src/ansiblelint/rules/yaml_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from ansiblelint.yaml_utils import load_yamllint_config

if TYPE_CHECKING:
from collections.abc import Generator
from typing import Any

from ansiblelint.errors import MatchError
Expand Down
2 changes: 1 addition & 1 deletion src/ansiblelint/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def worker(lintable: Lintable) -> list[MatchError]:

# avoid resource leak warning, https://github.com/python/cpython/issues/90549
# pylint: disable=unused-variable
global_resource = multiprocessing.Semaphore()
global_resource = multiprocessing.Semaphore() # noqa: F841

pool = multiprocessing.pool.ThreadPool(processes=multiprocessing.cpu_count())
return_list = pool.map(worker, files, chunksize=1)
Expand Down
2 changes: 1 addition & 1 deletion src/ansiblelint/schemas/__store__.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"ansible-lint-config": {
"etag": "e7ea18ea1332439262b2466c975765279cca544e9363a95b42796e6468ebf989",
"etag": "0d4587cd7a0c9dbc340b1933ac1e3fe2b7f0efbc70c2928910a84bd2f0eebf2d",
"url": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/ansible-lint-config.json"
},
"ansible-navigator-config": {
Expand Down
2 changes: 0 additions & 2 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
from ansiblelint.yaml_utils import FormattedYAML

if TYPE_CHECKING:
from typing import List # pylint: disable=ungrouped-imports

from _pytest import nodes
from _pytest.config import Config
from _pytest.config.argparsing import Parser
Expand Down
2 changes: 1 addition & 1 deletion test/test_transform_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

if TYPE_CHECKING:
from collections.abc import MutableMapping, MutableSequence
from typing import Any, Dict, List, Type, Union
from typing import Any


DUMMY_MAP: dict[str, Any] = {
Expand Down

0 comments on commit e221dd7

Please sign in to comment.