From d589c5ef8ae64194b9a750a238ea1dd19fdc59d6 Mon Sep 17 00:00:00 2001 From: Hugo Date: Thu, 26 Sep 2019 10:31:49 +0300 Subject: [PATCH 1/3] Add pre-commit and fix isort --- .pre-commit-config.yaml | 36 ++++++++++++++++++++++++++++++++++++ .travis.yml | 2 -- tests/test_librefm.py | 3 +-- tests/test_pylast.py | 4 +--- tests/unicode_test.py | 3 +-- tox.ini | 10 +++------- 6 files changed, 42 insertions(+), 16 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..ffb89cb --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,36 @@ +repos: + - repo: https://github.com/asottile/pyupgrade + rev: v1.24.0 + hooks: + - id: pyupgrade + + - repo: https://github.com/psf/black + rev: 19.3b0 + hooks: + - id: black + language_version: python3.7 + # override until resolved: https://github.com/psf/black/issues/402 + files: \.pyi?$ + types: [] + + - repo: https://gitlab.com/pycqa/flake8 + rev: 3.7.8 + hooks: + - id: flake8 + additional_dependencies: [flake8-2020] + + - repo: https://github.com/pre-commit/mirrors-isort + rev: v4.3.21 + hooks: + - id: isort + language_version: python3.7 + + - repo: https://github.com/pre-commit/pygrep-hooks + rev: v1.4.1 + hooks: + - id: python-check-blanket-noqa + + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.3.0 + hooks: + - id: check-yaml diff --git a/.travis.yml b/.travis.yml index 4aea714..36bcc05 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,6 @@ matrix: env: TOXENV=lint - python: 3.7 env: TOXENV=py37 - dist: xenial - python: 3.6 env: TOXENV=py36 - python: 3.5 @@ -27,7 +26,6 @@ matrix: env: TOXENV=pypy3 - python: 3.8-dev env: TOXENV=py38dev - dist: xenial allow_failures: - env: TOXENV=pypy3 fast_finish: true diff --git a/tests/test_librefm.py b/tests/test_librefm.py index dba0109..7f8d54b 100755 --- a/tests/test_librefm.py +++ b/tests/test_librefm.py @@ -4,9 +4,8 @@ Integration (not unit) tests for pylast.py """ import unittest -from flaky import flaky - import pylast +from flaky import flaky from .test_pylast import PyLastTestCase, load_secrets diff --git a/tests/test_pylast.py b/tests/test_pylast.py index b417fb8..75fb379 100755 --- a/tests/test_pylast.py +++ b/tests/test_pylast.py @@ -7,12 +7,10 @@ import sys import time import unittest +import pylast import pytest from flaky import flaky -import pylast - - PY37 = sys.version_info[:2] == (3, 7) diff --git a/tests/unicode_test.py b/tests/unicode_test.py index 062f37f..11e7ff7 100644 --- a/tests/unicode_test.py +++ b/tests/unicode_test.py @@ -1,8 +1,7 @@ # -*- coding: utf-8 -*- import mock -import pytest - import pylast +import pytest def mock_network(): diff --git a/tox.ini b/tox.ini index 9e62b74..a2eeafb 100644 --- a/tox.ini +++ b/tox.ini @@ -23,10 +23,6 @@ deps = ipdb commands = {posargs} [testenv:lint] -deps = - flake8 - pep8-naming - black -commands = - flake8 . - black --check --diff . +deps = pre-commit +commands = pre-commit run --all-files +skip_install = true From 3fd8280e33cc1c676eb84c004fbc822e65f5db0e Mon Sep 17 00:00:00 2001 From: Hugo Date: Thu, 26 Sep 2019 10:34:22 +0300 Subject: [PATCH 2/3] Update docstring: since 2016 get_weekly_artist_charts is only for users, not tags --- src/pylast/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pylast/__init__.py b/src/pylast/__init__.py index 7e8ad33..1d3f0ff 100644 --- a/src/pylast/__init__.py +++ b/src/pylast/__init__.py @@ -1251,7 +1251,7 @@ class _Chartable: """ Returns the weekly artist charts for the week starting from the from_date value to the to_date value. - Only for Tag or User. + Only for User. """ return self.get_weekly_charts("artist", from_date, to_date) From 99c434c0efc1d82f1282b1b52a5f95eada25a728 Mon Sep 17 00:00:00 2001 From: Hugo Date: Thu, 26 Sep 2019 10:36:16 +0300 Subject: [PATCH 3/3] Run lint on Python 3.7 --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 36bcc05..1a5a9fb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,8 +13,9 @@ env: - secure: SsKJoJwtDVWrL5xxl9C/gTRy6FhfRQQNNAFOogl9mTs/WeI2t9QTYoKsxLPXOdoRdu4MvT3h/B2sjwggt7zP81fBVxQRTkg4nq0zSHlj0NqclbFa6I5lUYdGwH9gPk/HWJJwXhKRDsqn/iRw2v+qBDs/j3kIgPQ0yjM58LEPXic= matrix: + fast_finish: true include: - - python: 3.6 + - python: 3.7 env: TOXENV=lint - python: 3.7 env: TOXENV=py37 @@ -28,7 +29,6 @@ matrix: env: TOXENV=py38dev allow_failures: - env: TOXENV=pypy3 - fast_finish: true install: - travis_retry pip install --upgrade pip @@ -49,7 +49,7 @@ deploy: tags: false repo: pylast/pylast branch: master - condition: $TOXENV = py37 + condition: $TOXENV = lint user: hugovk password: secure: "OCNT7Sf7TpS6aKuqBXEWxJZjmEpdERTBp/yllOd9xnpFt2ZL96CyKtAhPA8zu5OP58QFEZSafZRfXYJoz78RDrx3gOdRXCFT00vXIMnjVvrAlieNEHCVAT0kRW9lYK1Cf5baHYsOYIs6EZf2fEAhdzvmh83G4Y1Y+FPR9tA6uy8=" @@ -60,7 +60,7 @@ deploy: tags: true repo: pylast/pylast branch: master - condition: $TOXENV = py37 + condition: $TOXENV = lint user: hugovk password: secure: "OCNT7Sf7TpS6aKuqBXEWxJZjmEpdERTBp/yllOd9xnpFt2ZL96CyKtAhPA8zu5OP58QFEZSafZRfXYJoz78RDrx3gOdRXCFT00vXIMnjVvrAlieNEHCVAT0kRW9lYK1Cf5baHYsOYIs6EZf2fEAhdzvmh83G4Y1Y+FPR9tA6uy8="