fix python3.9 compatibility
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Tue, 5 Apr 2022 10:13:36 +0000 (12:13 +0200)
committerMarcel van der Veldt <m.vanderveldt@outlook.com>
Tue, 5 Apr 2022 10:13:36 +0000 (12:13 +0200)
17 files changed:
.github/workflows/test.yml
.pre-commit-config.yaml
music_assistant/helpers/audio.py
music_assistant/helpers/cache.py
music_assistant/helpers/compare.py
music_assistant/helpers/datetime.py
music_assistant/helpers/images.py
music_assistant/helpers/json.py
music_assistant/helpers/process.py
music_assistant/helpers/typing.py
music_assistant/helpers/util.py
music_assistant/providers/qobuz.py
music_assistant/providers/spotify/__init__.py
music_assistant/providers/tunein.py
pylintrc [new file with mode: 0644]
setup.py
tox.ini [deleted file]

index c392e6ede97cd20ff323a728e93b046d2b68fd09..8514e504e999ccb71bfe9ffaa0e39dc8d4cab7fd 100644 (file)
@@ -1,7 +1,7 @@
 # This workflow will install Python dependencies, run tests and lint
 # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
 
-name: Test with Pre-commit and Tox
+name: Test with Pre-commit
 
 on:
   push:
@@ -24,11 +24,8 @@ jobs:
           python-version: ${{ matrix.python-version }}
       - name: Install dependencies
         run: |
-          sudo apt-get install -y --no-install-recommends libsndfile1 libtag1v5 libtag1-dev
           python -m pip install --upgrade pip
-          pip install tox tox-gh-actions pre-commit
+          pip install pre-commit
           pre-commit install-hooks
-      - name: Lint with pre-commit
+      - name: Lint/test with pre-commit
         run: pre-commit run --all-files
-      - name: Test with tox
-        run: tox
index 2326ddea87a28e69dff8b1138c79256b3be5be93..f538b1610729f01ce0f95b1bd1819d225ee8af5c 100644 (file)
@@ -25,3 +25,13 @@ repos:
       - id: mypy
         additional_dependencies: [types-all]
         exclude: ^examples/
+  - repo: local
+    hooks:
+      - id: pylint
+        name: pylint
+        entry: pylint
+        language: system
+        types: [python]
+        args: ["-rn", "-sn", "--rcfile=pylintrc", "--fail-on=I"]
+        exclude: ^examples/|^.venv/|^.vscode/
+
index 3e9ffe3090bd6d953f5260a095c72fd062a7e460..a908fbdcc32fb8e28d14ffa2728290dc48d4e989 100644 (file)
@@ -1,4 +1,5 @@
 """Various helpers for audio manipulation."""
+from __future__ import annotations
 
 import asyncio
 import logging
index 404b016d35f5003f02b33b14937a839069b3655e..a6444708f1a476bb776de96d1ae398bb2ba347a8 100644 (file)
@@ -1,4 +1,5 @@
 """Provides a simple stateless caching system."""
+from __future__ import annotations
 
 import asyncio
 import functools
index c86f670ede56e8dfdb05c150f9735827a006d982..55a7ff29172228865e0a9367f3954e2507fd2d06 100644 (file)
@@ -1,4 +1,6 @@
 """Several helper/utils to compare objects."""
+from __future__ import annotations
+
 import re
 from typing import TYPE_CHECKING, List
 
index 3373c0bfc146b3f47194ed8ed80fc10d602ea44b..402e833fad473f3f83495cf54edaf89910cb8fdf 100644 (file)
@@ -1,4 +1,5 @@
 """Helpers for date and time."""
+from __future__ import annotations
 
 import datetime
 
index fe0d691ecd6acfef670ce439b321064667dd2e5e..c6b922071cc94003d1a58a8a9f98ecc82b159de5 100644 (file)
@@ -1,4 +1,5 @@
 """Utilities for image manipulation and retrieval."""
+from __future__ import annotations
 
 from io import BytesIO
 
index 4a3b1a37ecf0a09321e31a2ea2a91899fdfd213e..7065cc5b78d7133b918f4a868ea0fce57eba1a73 100644 (file)
@@ -1,4 +1,5 @@
 """Various helpers for web requests."""
+from __future__ import annotations
 
 import asyncio
 
index eed32d62a30e1b01408a313c30a3f3ab49035532..76979dc2d23072e19777f2fc8a666f9ecaebf13b 100644 (file)
@@ -4,6 +4,7 @@ Implementation of a (truly) non blocking subprocess.
 The subprocess implementation in asyncio can (still) sometimes cause deadlocks,
 even when properly handling reading/writes from different tasks.
 """
+from __future__ import annotations
 
 import asyncio
 import logging
index 0debc056a1e32a05f39ef0eceadff8bf5f9cbb32..1caf05f9f0321ab7baff4dfeb3c1b40c7e3e0de8 100644 (file)
@@ -1,4 +1,5 @@
 """Typing helper."""
+from __future__ import annotations
 
 from typing import TYPE_CHECKING, Any, List, Optional
 
index 6743b7336936e40cb86620aae51bc5a66a938d38..43a59913613df099f5ef32765ba77483fc387781 100755 (executable)
@@ -1,4 +1,6 @@
 """Helper and utility functions."""
+from __future__ import annotations
+
 import asyncio
 import functools
 import os
index 669949e70eee7f843302e419eec87104d3f9fd9e..5432de93ce0c40443a8a10d5e3b6c2d85b9381fc 100644 (file)
@@ -1,4 +1,5 @@
 """Qobuz musicprovider support for MusicAssistant."""
+from __future__ import annotations
 
 import datetime
 import hashlib
index 68cc568afda2453972caf5aa89edcb0e1b370438..1c343f028fa1047b2ecf7012d4fce69169c77f50 100644 (file)
@@ -1,4 +1,6 @@
 """Spotify musicprovider support for MusicAssistant."""
+from __future__ import annotations
+
 import asyncio
 import json
 import os
index d5496ac7e6ce9751587b6d8788ea5f8ac3a8ed8f..f392aa4ed9be470e12dee5df49179cf3eee85f5a 100644 (file)
@@ -1,4 +1,6 @@
 """Tune-In musicprovider support for MusicAssistant."""
+from __future__ import annotations
+
 from typing import List, Optional
 
 from asyncio_throttle import Throttler
diff --git a/pylintrc b/pylintrc
new file mode 100644 (file)
index 0000000..0b60c45
--- /dev/null
+++ b/pylintrc
@@ -0,0 +1,69 @@
+[MASTER]
+ignore=tests
+ignore-patterns=app_vars
+# Use a conservative default here; 2 should speed up most setups and not hurt
+# any too bad. Override on command line as appropriate.
+jobs=2
+persistent=no
+suggestion-mode=yes
+extension-pkg-whitelist=taglib
+
+[BASIC]
+good-names=id,i,j,k,ex,Run,_,fp,T,ev
+
+[MESSAGES CONTROL]
+# Reasons disabled:
+# format - handled by black
+# locally-disabled - it spams too much
+# duplicate-code - unavoidable
+# cyclic-import - doesn't test if both import on load
+# abstract-class-little-used - prevents from setting right foundation
+# unused-argument - generic callbacks and setup methods create a lot of warnings
+# too-many-* - are not enforced for the sake of readability
+# too-few-* - same as too-many-*
+# abstract-method - with intro of async there are always methods missing
+# inconsistent-return-statements - doesn't handle raise
+# too-many-ancestors - it's too strict.
+# wrong-import-order - isort guards this
+# fixme - project is in development phase
+disable=
+  format,
+  abstract-class-little-used,
+  abstract-method,
+  cyclic-import,
+  duplicate-code,
+  inconsistent-return-statements,
+  locally-disabled,
+  not-context-manager,
+  too-few-public-methods,
+  too-many-ancestors,
+  too-many-arguments,
+  too-many-branches,
+  too-many-instance-attributes,
+  too-many-lines,
+  too-many-locals,
+  too-many-public-methods,
+  too-many-return-statements,
+  too-many-statements,
+  too-many-boolean-expressions,
+  unused-argument,
+  wrong-import-order,
+  fixme
+# enable useless-suppression temporarily every now and then to clean them up
+enable=
+  use-symbolic-message-instead
+
+[REPORTS]
+score=no
+
+[REFACTORING]
+
+# Maximum number of nested blocks for function / method body
+max-nested-blocks=15
+
+[TYPECHECK]
+# For attrs
+ignored-classes=_CountingAttr
+
+[FORMAT]
+expected-line-ending-format=LF
\ No newline at end of file
index addbe2be303fd0e2b074f200926cb949116f6107..e05b2d05e123e38398a53f629f8f6368e116c6d6 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -28,15 +28,13 @@ PROJECT_URLS = {
 }
 PROJECT_DIR = Path(__file__).parent.resolve()
 README_FILE = PROJECT_DIR / "README.rst"
+REQUIREMENTS_FILE = PROJECT_DIR / "requirements.txt"
 PACKAGES = find_packages(exclude=["tests", "tests.*"])
 PACKAGE_FILES = []
 for (path, directories, filenames) in os.walk("music_assistant/"):
     for filename in filenames:
         PACKAGE_FILES.append(os.path.join("..", path, filename))
 
-with open("requirements.txt") as f:
-    REQUIRES = f.read().splitlines()
-
 setup(
     name=PROJECT_PACKAGE_NAME,
     version=PROJECT_VERSION,
@@ -50,7 +48,7 @@ setup(
     packages=PACKAGES,
     include_package_data=True,
     zip_safe=False,
-    install_requires=REQUIRES,
+    install_requires=REQUIREMENTS_FILE.read_text(encoding="utf-8"),
     python_requires=f">={PROJECT_REQ_PYTHON_VERSION}",
     test_suite="tests",
     entry_points={
diff --git a/tox.ini b/tox.ini
deleted file mode 100644 (file)
index 41bc3bf..0000000
--- a/tox.ini
+++ /dev/null
@@ -1,28 +0,0 @@
-[tox]
-envlist = py39, py310, lint, mypy
-skip_missing_interpreters = True
-
-[gh-actions]
-python =
-  3.9: py39, lint, mypy
-  3.10: py310
-
-[testenv:lint]
-basepython = python3
-ignore_errors = True
-commands =
-  black --check ./
-  flake8 music_assistant tests
-  pylint music_assistant tests
-  pydocstyle music_assistant tests
-deps =
-  -rrequirements_lint.txt
-  -rrequirements_test.txt
-
-[testenv:mypy]
-basepython = python3
-ignore_errors = True
-commands =
-  mypy music_assistant
-deps =
-  -rrequirements_lint.txt
\ No newline at end of file