Verified Commit 5a4631fa authored by Georg Krause's avatar Georg Krause
Browse files

Lint codebase and add CI job

parent 9c9d3927
Pipeline #19020 failed with stages
in 1 minute and 39 seconds
stages:
- lint
- test
- build
- publish
lint:
stage: lint
image: python:3.10
before_script:
- pip install .[lint]
script:
- black .
tags:
- docker
test:
stage: test
image: python:3
......
......@@ -78,7 +78,9 @@ class APIClient(object):
)
self.session.verify = config["funkwhale"].get("verify_cert", True)
self.exclude_compilation_artists = self.config["funkwhale"].get("exclude_compilation_artists", True)
self.exclude_compilation_artists = self.config["funkwhale"].get(
"exclude_compilation_artists", True
)
@property
def use_oauth(self):
......@@ -151,7 +153,9 @@ def get_token(config):
return None
try:
token_data = json.loads(raw)
token_data["expires_in"] = token_data["expires_at"] - datetime.timestamp(datetime.now())
token_data["expires_in"] = token_data["expires_at"] - datetime.timestamp(
datetime.now()
)
return token_data
except (TypeError, ValueError):
logger.error("Cannot decode token data, you may need to relogin")
......
......@@ -293,7 +293,7 @@ class FunkwhaleLibraryProvider(backend.LibraryProvider):
logger.debug("Handling libraries route: %s", remaining)
payload = self.backend.client.list_libraries(
{"ordering": "name", "page_size": 50}
{"ordering": "name", "page_size": 50}
)
uri_prefix = "funkwhale:directory:artists:by-library"
libraries = [
......@@ -378,7 +378,9 @@ class FunkwhaleLibraryProvider(backend.LibraryProvider):
client = self.backend.client
config = {
"track": lambda id: [client.get_track(id)],
"album": lambda id: client.list_tracks({"album": id, "ordering": "position"})["results"],
"album": lambda id: client.list_tracks(
{"album": id, "ordering": "position"}
)["results"],
"artist": lambda id: client.list_tracks({"artist": id})["results"],
}
......
......@@ -28,6 +28,9 @@ mopidy.ext =
funkwhale = mopidy_funkwhale:Extension
[options.extras_require]
lint =
black
test =
pytest
pytest-cov
......
......@@ -4,24 +4,27 @@ import codecs
import os
from setuptools import setup
def read(rel_path):
here = os.path.abspath(os.path.dirname(__file__))
with codecs.open(os.path.join(here, rel_path), 'r') as fp:
with codecs.open(os.path.join(here, rel_path), "r") as fp:
return fp.read()
def get_version():
tag = os.getenv('CI_COMMIT_TAG', None)
tag = os.getenv("CI_COMMIT_TAG", None)
if tag:
return tag
for line in read("mopidy_funkwhale/__init__.py").splitlines():
if line.startswith('__version__'):
if line.startswith("__version__"):
delim = '"' if '"' in line else "'"
version = line.split(delim)[1]
iid = os.getenv('CI_PIPELINE_IID', 0)
iid = os.getenv("CI_PIPELINE_IID", 0)
return "{}.dev{}".format(version, iid)
raise RuntimeError("Unable to find version string.")
setup(
version=get_version(),
)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment