Skip to content

Commit

Permalink
Use ruff instead of isort, pylint and flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasberbuer committed Feb 17, 2023
1 parent 37732e3 commit 1621141
Show file tree
Hide file tree
Showing 14 changed files with 39 additions and 65 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ jobs:
run: pip install tox
- name: Run black
run: tox -e black
- name: Run isort
run: tox -e isort
- name: Run pylint
run: tox -e pylint
- name: Run ruff
run: tox -e ruff
- name: Run mypy
run: tox -e mypy
- name: Run pytest (Conan v1)
Expand Down
23 changes: 4 additions & 19 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,11 @@ repos:
rev: 22.12.0
hooks:
- id: black
- repo: "https://github.com/PyCQA/isort"
rev: 5.11.2
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.247
hooks:
- id: isort
- repo: "https://github.com/PyCQA/flake8"
rev: 6.0.0
hooks:
- id: flake8
args: [--max-line-length=100]
additional_dependencies:
- flake8-bugbear
- flake8-builtins
- flake8-comprehensions
- flake8-logging-format
- flake8-pytest-style
- flake8-simplify
- repo: "https://github.com/PyCQA/pylint"
rev: v2.15.8
hooks:
- id: pylint
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: "https://github.com/pre-commit/mirrors-mypy"
rev: v0.991
hooks:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
[![PyPI](https://img.shields.io/pypi/v/conan-check-updates)](https://pypi.org/project/conan-check-updates)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/conan-check-updates)](https://pypi.org/project/conan-check-updates)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v1.json)](https://github.com/charliermarsh/ruff)

Check for updates of your `conanfile.txt` / `conanfile.py` requirements.

Expand Down
58 changes: 28 additions & 30 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,28 +70,33 @@ Issues = "https://github.com/lukasberbuer/conan-check-updates/issues"
line-length = 100


[tool.isort]
profile = "black"


[tool.pylint.format]
max-line-length = 100

[tool.pylint.message_control]
good-names=[
"e", "i", "j", "n", "r", "v", "it"
[tool.ruff]
line-length = 100
select = [
"F", # pyflakes
"E", "W", # pycodestyle
"I", # isort
"N", # pep8 naming
"B", # flake8 bugbear
"A", # flake8 builtins
"C4", # flake8 comprehensions
"G", # flake8 logging format
"PIE", # flake8 pie
"RET", # flake8 return
"SIM", # flake8 simplify
"PT", # flake8 pytest style
"PL", # pylint
"RUF", # ruff specific rules
]
disable = [
"import-error",
"missing-module-docstring",
"missing-class-docstring",
"missing-function-docstring",
"too-few-public-methods",
"too-many-arguments",
ignore = [
"PLR0911", # too many return statements
]

[tool.pylint.similarities]
min-similarity-lines = 6
[tool.ruff.per-file-ignores]
"tests/*" = [
"PLR0913", # too many arguments
"PLR2004", # magic value
]


[tool.mypy]
Expand Down Expand Up @@ -119,8 +124,7 @@ legacy_tox_ini = """
[tox]
envlist =
black
isort
pylint
ruff
mypy
py{37, 38, 39, 310, 311}-{v1, v2}
coverage-report
Expand All @@ -132,17 +136,11 @@ commands =
black --diff .
black --check .
[testenv:isort]
[testenv:ruff]
skip_install = true
deps = isort
deps = ruff
commands =
isort --diff .
isort --check-only .
[testenv:pylint]
skip_install = true
deps = pylint
commands = pylint ./src/
ruff check .
[testenv:mypy]
skip_install = true
Expand Down
2 changes: 1 addition & 1 deletion src/conan_check_updates/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def highlighted_version_difference(version: VersionLike, compare: VersionLike) -
version = str(version)
compare = str(compare)
i_first_diff = next(
(i for i, (s1, s2) in enumerate(zip(version, compare)) if s1 != s2),
(i for i, (s1, s2) in enumerate(zip(version, compare)) if s1 != s2), # noqa: B905
None,
)
if i_first_diff is None:
Expand Down
4 changes: 2 additions & 2 deletions src/conan_check_updates/conan.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def get_command():
if conan_version().major == 1:
args = chain.from_iterable(("-a", attr) for attr in _REQUIRES_ATTRIBUTES)
return ("conan", "inspect", str(conanfile), *args)
if conan_version().major == 2:
if conan_version().major == 2: # noqa: PLR2004
return ("conan", "inspect", str(conanfile))
raise RuntimeError(f"Conan version {str(conan_version())} not supported")

Expand Down Expand Up @@ -257,7 +257,7 @@ async def search(
def get_command():
if conan_version().major == 1:
return ("conan", "search", pattern, "--remote", "all", "--raw")
if conan_version().major == 2:
if conan_version().major == 2: # noqa: PLR2004
return ("conan", "search", pattern)
raise RuntimeError(f"Conan version {str(conan_version())} not supported")

Expand Down
1 change: 0 additions & 1 deletion src/conan_check_updates/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ def __eq__(self, other) -> bool:
return self.astuple() == other.astuple()

def __lt__(self, other) -> bool:
# pylint: disable=too-many-return-statements
# semver precedence: https://semver.org/#spec-item-11
if isinstance(other, str):
other = Version(other, loose=self._loose)
Expand Down
1 change: 0 additions & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from pathlib import Path

import pytest

from conan_check_updates.cli import parse_args
from conan_check_updates.version import VersionPart

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

from conan_check_updates.color import AnsiCodes, colored


Expand Down
1 change: 0 additions & 1 deletion tests/test_conan.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
... # skip tests for Python < 3.8

import pytest

from conan_check_updates.conan import (
ConanError,
ConanReference,
Expand Down
3 changes: 1 addition & 2 deletions tests/test_conan_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
from unittest.mock import patch

import pytest
from test_conan import parse_requires_conanfile_json

from conan_check_updates.conan import (
ConanReference,
conan_version,
inspect_requires_conanfile,
search_versions_parallel,
)
from conan_check_updates.version import Version
from test_conan import parse_requires_conanfile_json

HERE = Path(__file__).parent

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

from conan_check_updates.filter import matches_any


Expand Down
1 change: 0 additions & 1 deletion tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from unittest.mock import Mock, call, patch

import pytest

from conan_check_updates.conan import ConanReference, ConanSearchVersionsResult
from conan_check_updates.main import CheckUpdateResult, check_updates, upgrade_conanfile
from conan_check_updates.version import Version, VersionLike, VersionPart
Expand Down
1 change: 0 additions & 1 deletion tests/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from typing import List, Optional

import pytest

from conan_check_updates.version import (
Version,
VersionError,
Expand Down

0 comments on commit 1621141

Please sign in to comment.