Replace Flake8 with Ruff
This commit is contained in:
parent
a28dea1158
commit
36d89a69e8
|
@ -1,12 +1,12 @@
|
|||
repos:
|
||||
- repo: https://github.com/asottile/pyupgrade
|
||||
rev: v3.15.0
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
rev: v0.2.0
|
||||
hooks:
|
||||
- id: pyupgrade
|
||||
args: [--py38-plus]
|
||||
- id: ruff
|
||||
args: [--fix, --exit-non-zero-on-fix]
|
||||
|
||||
- repo: https://github.com/psf/black-pre-commit-mirror
|
||||
rev: 23.12.1
|
||||
rev: 24.1.1
|
||||
hooks:
|
||||
- id: black
|
||||
|
||||
|
@ -15,24 +15,7 @@ repos:
|
|||
hooks:
|
||||
- id: blacken-docs
|
||||
args: [--target-version=py38]
|
||||
additional_dependencies: [black==23.3.0]
|
||||
|
||||
- repo: https://github.com/PyCQA/isort
|
||||
rev: 5.13.2
|
||||
hooks:
|
||||
- id: isort
|
||||
|
||||
- repo: https://github.com/PyCQA/flake8
|
||||
rev: 6.1.0
|
||||
hooks:
|
||||
- id: flake8
|
||||
additional_dependencies: [flake8-2020, flake8-implicit-str-concat]
|
||||
|
||||
- repo: https://github.com/pre-commit/pygrep-hooks
|
||||
rev: v1.10.0
|
||||
hooks:
|
||||
- id: python-check-blanket-noqa
|
||||
- id: python-no-log-warn
|
||||
additional_dependencies: [black]
|
||||
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v4.5.0
|
||||
|
@ -42,19 +25,19 @@ repos:
|
|||
- id: check-json
|
||||
- id: check-toml
|
||||
- id: check-yaml
|
||||
- id: debug-statements
|
||||
- id: end-of-file-fixer
|
||||
- id: requirements-txt-fixer
|
||||
- id: trailing-whitespace
|
||||
exclude: .github/(ISSUE_TEMPLATE|PULL_REQUEST_TEMPLATE).md
|
||||
|
||||
- repo: https://github.com/tox-dev/pyproject-fmt
|
||||
rev: 1.5.3
|
||||
rev: 1.7.0
|
||||
hooks:
|
||||
- id: pyproject-fmt
|
||||
additional_dependencies: [tox]
|
||||
|
||||
- repo: https://github.com/abravalheri/validate-pyproject
|
||||
rev: v0.15
|
||||
rev: v0.16
|
||||
hooks:
|
||||
- id: validate-pyproject
|
||||
|
||||
|
@ -63,5 +46,10 @@ repos:
|
|||
hooks:
|
||||
- id: tox-ini-fmt
|
||||
|
||||
- repo: meta
|
||||
hooks:
|
||||
- id: check-hooks-apply
|
||||
- id: check-useless-excludes
|
||||
|
||||
ci:
|
||||
autoupdate_schedule: quarterly
|
||||
|
|
|
@ -59,5 +59,28 @@ version.source = "vcs"
|
|||
[tool.hatch.version.raw-options]
|
||||
local_scheme = "no-local-version"
|
||||
|
||||
[tool.isort]
|
||||
profile = "black"
|
||||
[tool.ruff.lint]
|
||||
select = [
|
||||
"C4", # flake8-comprehensions
|
||||
"E", # pycodestyle errors
|
||||
"EM", # flake8-errmsg
|
||||
"F", # pyflakes errors
|
||||
"I", # isort
|
||||
"ISC", # flake8-implicit-str-concat
|
||||
"LOG", # flake8-logging
|
||||
"PGH", # pygrep-hooks
|
||||
"RUF100", # unused noqa (yesqa)
|
||||
"UP", # pyupgrade
|
||||
"W", # pycodestyle warnings
|
||||
"YTT", # flake8-2020
|
||||
]
|
||||
extend-ignore = [
|
||||
"E203", # Whitespace before ':'
|
||||
"E221", # Multiple spaces before operator
|
||||
"E226", # Missing whitespace around arithmetic operator
|
||||
"E241", # Multiple spaces after ','
|
||||
]
|
||||
|
||||
[tool.ruff.lint.isort]
|
||||
known-first-party = ["pylast"]
|
||||
required-imports = ["from __future__ import annotations"]
|
||||
|
|
|
@ -628,7 +628,6 @@ class _Network:
|
|||
|
||||
|
||||
class LastFMNetwork(_Network):
|
||||
|
||||
"""A Last.fm network object
|
||||
|
||||
api_key: a provided API_KEY
|
||||
|
@ -1243,8 +1242,10 @@ class _Chartable(_BaseObject):
|
|||
from_date value to the to_date value.
|
||||
chart_kind should be one of "album", "artist" or "track"
|
||||
"""
|
||||
import sys
|
||||
|
||||
method = ".getWeekly" + chart_kind.title() + "Chart"
|
||||
chart_type = eval(chart_kind.title()) # string to type
|
||||
chart_type = getattr(sys.modules[__name__], chart_kind.title())
|
||||
|
||||
params = self._get_params()
|
||||
if from_date and to_date:
|
||||
|
@ -1356,11 +1357,11 @@ class _Taggable(_BaseObject):
|
|||
new_tags.append(tag)
|
||||
|
||||
for i in range(0, len(old_tags)):
|
||||
if not c_old_tags[i] in c_new_tags:
|
||||
if c_old_tags[i] not in c_new_tags:
|
||||
to_remove.append(old_tags[i])
|
||||
|
||||
for i in range(0, len(new_tags)):
|
||||
if not c_new_tags[i] in c_old_tags:
|
||||
if c_new_tags[i] not in c_old_tags:
|
||||
to_add.append(new_tags[i])
|
||||
|
||||
self.remove_tags(to_remove)
|
||||
|
@ -2778,7 +2779,8 @@ def _collect_nodes(
|
|||
main.getAttribute("totalPages") or main.getAttribute("totalpages")
|
||||
)
|
||||
else:
|
||||
raise PyLastError("No total pages attribute")
|
||||
msg = "No total pages attribute"
|
||||
raise PyLastError(msg)
|
||||
|
||||
for node in main.childNodes:
|
||||
if not node.nodeType == xml.dom.Node.TEXT_NODE and (
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
"""
|
||||
Integration (not unit) tests for pylast.py
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import pylast
|
||||
|
||||
from .test_pylast import TestPyLastWithLastFm
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
"""
|
||||
Integration (not unit) tests for pylast.py
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
import pylast
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
"""
|
||||
Integration (not unit) tests for pylast.py
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import pylast
|
||||
|
||||
from .test_pylast import TestPyLastWithLastFm
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
"""
|
||||
Integration (not unit) tests for pylast.py
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import pylast
|
||||
|
||||
from .test_pylast import TestPyLastWithLastFm
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
"""
|
||||
Integration (not unit) tests for pylast.py
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from flaky import flaky
|
||||
|
||||
import pylast
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
"""
|
||||
Integration (not unit) tests for pylast.py
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
import time
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
"""
|
||||
Integration (not unit) tests for pylast.py
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import time
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
"""
|
||||
Integration (not unit) tests for pylast.py
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import pylast
|
||||
|
||||
from .test_pylast import TestPyLastWithLastFm
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
"""
|
||||
Integration (not unit) tests for pylast.py
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import time
|
||||
|
||||
import pytest
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
"""
|
||||
Integration (not unit) tests for pylast.py
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import calendar
|
||||
import datetime as dt
|
||||
import inspect
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
|
@ -25,7 +27,7 @@ def test_get_cache_key(artist) -> None:
|
|||
|
||||
@pytest.mark.parametrize("obj", [pylast.Artist("B\xe9l", mock_network())])
|
||||
def test_cast_and_hash(obj) -> None:
|
||||
assert type(str(obj)) is str
|
||||
assert isinstance(str(obj), str)
|
||||
assert isinstance(hash(obj), int)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue