diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 1480fa1..5b2dc65 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -12,8 +12,11 @@ Please include **code** that reproduces the issue. -The [best reproductions](https://stackoverflow.com/help/minimal-reproducible-example) are [self-contained scripts](https://ericlippert.com/2014/03/05/how-to-debug-small-programs/) with minimal dependencies. +The [best reproductions](https://stackoverflow.com/help/minimal-reproducible-example) +are +[self-contained scripts](https://ericlippert.com/2014/03/05/how-to-debug-small-programs/) +with minimal dependencies. ```python -code goes here +# code goes here ``` diff --git a/.github/labels.yml b/.github/labels.yml index 13ae9e0..38b5fdb 100644 --- a/.github/labels.yml +++ b/.github/labels.yml @@ -97,12 +97,18 @@ - color: 0366d6 description: "For dependencies" name: dependencies +- color: 0052cc + description: "Documentation" + name: docs - color: f4660e description: "" name: Hacktoberfest - color: f4660e description: "To credit accepted Hacktoberfest PRs" name: hacktoberfest-accepted +- color: d65e88 + description: "Deploy and release" + name: release - color: fef2c0 - description: "" + description: "Unit tests, linting, CI, etc." name: test diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index c121b37..834488e 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -23,7 +23,6 @@ exclude-labels: - "changelog: skip" template: | - ## Changes $CHANGES diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index bda0c64..f092b74 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -3,7 +3,7 @@ name: Lint on: [push, pull_request] jobs: - build: + lint: runs-on: ubuntu-20.04 steps: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 12e6357..e8b978a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -47,7 +47,6 @@ jobs: python -m pip install -U tox - name: Tox tests - shell: bash run: | tox -e py env: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fe64f0d..b29fb44 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,6 +14,13 @@ repos: files: \.pyi?$ types: [] + - repo: https://github.com/asottile/blacken-docs + rev: v1.9.1 + hooks: + - id: blacken-docs + args: ["--target-version", "py36"] + additional_dependencies: [black==20.8b1] + - repo: https://github.com/PyCQA/isort rev: 5.7.0 hooks: diff --git a/README.md b/README.md index 1cd834a..fb05c3b 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,8 @@ pyLast [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) [![DOI](https://zenodo.org/badge/7803088.svg)](https://zenodo.org/badge/latestdoi/7803088) -A Python interface to [Last.fm](https://www.last.fm/) and other API-compatible websites such as [Libre.fm](https://libre.fm/). +A Python interface to [Last.fm](https://www.last.fm/) and other API-compatible websites +such as [Libre.fm](https://libre.fm/). Use the pydoc utility for help on usage or see [tests/](tests/) for examples. @@ -18,25 +19,31 @@ Installation Install via pip: - pip install pylast +```sh +python3 -m pip install pylast +``` Install latest development version: - pip install -U git+https://github.com/pylast/pylast +```sh +python3 -m pip install -U git+https://github.com/pylast/pylast +``` Or from requirements.txt: - -e git://github.com/pylast/pylast.git#egg=pylast +```txt +-e git://github.com/pylast/pylast.git#egg=pylast +``` Note: -* pyLast 4.0.0+ supports Python 3.6-3.9. -* pyLast 3.2.0 - 3.3.0 supports Python 3.5-3.8. -* pyLast 3.0.0 - 3.1.0 supports Python 3.5-3.7. -* pyLast 2.2.0 - 2.4.0 supports Python 2.7.10+, 3.4-3.7. -* pyLast 2.0.0 - 2.1.0 supports Python 2.7.10+, 3.4-3.6. -* pyLast 1.7.0 - 1.9.0 supports Python 2.7, 3.3-3.6. -* pyLast 1.0.0 - 1.6.0 supports Python 2.7, 3.3-3.4. +* pyLast 4.0+ supports Python 3.6-3.9. +* pyLast 3.2 - 3.3 supports Python 3.5-3.8. +* pyLast 3.0 - 3.1 supports Python 3.5-3.7. +* pyLast 2.2 - 2.4 supports Python 2.7.10+, 3.4-3.7. +* pyLast 2.0 - 2.1 supports Python 2.7.10+, 3.4-3.6. +* pyLast 1.7 - 1.9 supports Python 2.7, 3.3-3.6. +* pyLast 1.0 - 1.6 supports Python 2.7, 3.3-3.4. * pyLast 0.5 supports Python 2, 3. * pyLast < 0.5 supports Python 2. @@ -55,7 +62,10 @@ Features Getting started --------------- -Here's some simple code example to get you started. In order to create any object from pyLast, you need a `Network` object which represents a social music network that is Last.fm or any other API-compatible one. You can obtain a pre-configured one for Last.fm and use it as follows: +Here's some simple code example to get you started. In order to create any object from +pyLast, you need a `Network` object which represents a social music network that is +Last.fm or any other API-compatible one. You can obtain a pre-configured one for Last.fm +and use it as follows: ```python import pylast @@ -69,8 +79,12 @@ API_SECRET = "425b55975eed76058ac220b7b4e8a054" username = "your_user_name" password_hash = pylast.md5("your_password") -network = pylast.LastFMNetwork(api_key=API_KEY, api_secret=API_SECRET, - username=username, password_hash=password_hash) +network = pylast.LastFMNetwork( + api_key=API_KEY, + api_secret=API_SECRET, + username=username, + password_hash=password_hash, +) # Now you can use that object everywhere artist = network.get_artist("System of a Down") @@ -85,14 +99,20 @@ track.add_tags(("awesome", "favorite")) # to get more help about anything and see examples of how it works ``` -More examples in hugovk/lastfm-tools and [tests/](tests/). +More examples in +hugovk/lastfm-tools and +[tests/](https://github.com/pylast/pylast/tree/master/tests). Testing ------- -The [tests/](tests/) directory contains integration and unit tests with Last.fm, and plenty of code examples. +The [tests/](https://github.com/pylast/pylast/tree/master/tests) directory contains +integration and unit tests with Last.fm, and plenty of code examples. -For integration tests you need a test account at Last.fm that will become cluttered with test data, and an API key and secret. Either copy [example_test_pylast.yaml](example_test_pylast.yaml) to test_pylast.yaml and fill out the credentials, or set them as environment variables like: +For integration tests you need a test account at Last.fm that will become cluttered with +test data, and an API key and secret. Either copy +[example_test_pylast.yaml](example_test_pylast.yaml) to test_pylast.yaml and fill out +the credentials, or set them as environment variables like: ```sh export PYLAST_USERNAME=TODO_ENTER_YOURS_HERE @@ -102,17 +122,20 @@ export PYLAST_API_SECRET=TODO_ENTER_YOURS_HERE ``` To run all unit and integration tests: + ```sh -pip install -e ".[tests]" +python3 -m pip install -e ".[tests]" pytest ``` Or run just one test case: + ```sh pytest -k test_scrobble ``` To run with coverage: + ```sh pytest -v --cov pylast --cov-report term-missing coverage report # for command-line report diff --git a/src/pylast/__init__.py b/src/pylast/__init__.py index 05c0361..02db07c 100644 --- a/src/pylast/__init__.py +++ b/src/pylast/__init__.py @@ -3,7 +3,7 @@ # A Python interface to Last.fm and Libre.fm # # Copyright 2008-2010 Amr Hassan -# Copyright 2013-2020 hugovk +# Copyright 2013-2021 hugovk # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -35,7 +35,7 @@ from xml.dom import Node, minidom import pkg_resources __author__ = "Amr Hassan, hugovk, Mice Pápai" -__copyright__ = "Copyright (C) 2008-2010 Amr Hassan, 2013-2020 hugovk, 2017 Mice Pápai" +__copyright__ = "Copyright (C) 2008-2010 Amr Hassan, 2013-2021 hugovk, 2017 Mice Pápai" __license__ = "apache2" __email__ = "amr.hassan@gmail.com" __version__ = pkg_resources.get_distribution(__name__).version diff --git a/tests/test_pylast.py b/tests/test_pylast.py index 4c39f33..26f799c 100755 --- a/tests/test_pylast.py +++ b/tests/test_pylast.py @@ -11,7 +11,7 @@ from flaky import flaky import pylast -WRITE_TEST = sys.version_info[:2] == (3, 8) +WRITE_TEST = sys.version_info[:2] == (3, 9) def load_secrets(): # pragma: no cover