Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manually run mypy, black and ruff #40

Merged
merged 1 commit into from
Jan 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -19,7 +19,6 @@ types-requests = "^2.31.0.1"
types-python-dateutil = "^2.8.19.14"
responses = "^0.23.1"
ruff = "^0.0.280"
sphinx = "^7.1.0"

[build-system]
requires = ["poetry-core"]
4 changes: 3 additions & 1 deletion src/knuckles/models/playlist.py
Original file line number Diff line number Diff line change
@@ -73,7 +73,9 @@ def __init__(
self.public = public
self.cover_art = CoverArt(coverArt) if coverArt else None
self.allowed_users = (
[User(self.__subsonic, username) for username in allowedUser] if allowedUser else None
[User(self.__subsonic, username) for username in allowedUser]
if allowedUser
else None
)
self.songs = (
[Song(self.__subsonic, **song) for song in entry] if entry else None
16 changes: 5 additions & 11 deletions src/knuckles/models/user.py
Original file line number Diff line number Diff line change
@@ -81,9 +81,7 @@ def generate(self) -> "User":

self.__check_api_access()

return self.subsonic.user_management.get_user( # type: ignore[union-attr]
self.username
)
return self.subsonic.user_management.get_user(self.username)

def create(self) -> Self:
"""Calls the "createUser" endpoint of the API.
@@ -118,7 +116,7 @@ def create(self) -> Self:
self.video_conversion_role,
self.music_folder_id,
self.max_bit_rate,
) # type: ignore[union-attr]
)

return self

@@ -154,7 +152,7 @@ def update(self) -> Self:
self.video_conversion_role,
self.music_folder_id,
self.max_bit_rate,
) # type: ignore[union-attr]
)

return self

@@ -168,9 +166,7 @@ def delete(self) -> Self:

self.__check_api_access()

self.subsonic.user_management.delete_user( # type: ignore[union-attr]
self.username
)
self.subsonic.user_management.delete_user(self.username)

return self

@@ -189,8 +185,6 @@ def change_password(self, new_password: str) -> Self:

self.__check_api_access()

self.subsonic.user_management.change_password( # type: ignore[union-attr]
self.username, new_password
)
self.subsonic.user_management.change_password(self.username, new_password)

return self
53 changes: 29 additions & 24 deletions src/knuckles/user_management.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import TYPE_CHECKING, Any
from typing import TYPE_CHECKING

from .api import Api
from .models.user import User
@@ -61,27 +61,29 @@ def get_users(self) -> list[User]:

users: list[User] = []
for user in request:
users.append(User(
self.subsonic,
user["username"],
user["password"],
user["email"],
user["ldapAuthenticated"],
user["adminRole"],
user["settingsRole"],
user["streamRole"],
user["jukeboxRole"],
user["downloadRole"],
user["uploadRole"],
user["playlistRole"],
user["coverArtRole"],
user["commentRole"],
user["podcastRole"],
user["shareRole"],
user["videoConversionRole"],
user["musicFolderId"],
user["maxBitRate"],
))
users.append(
User(
self.subsonic,
user["username"],
user["password"],
user["email"],
user["ldapAuthenticated"],
user["adminRole"],
user["settingsRole"],
user["streamRole"],
user["jukeboxRole"],
user["downloadRole"],
user["uploadRole"],
user["playlistRole"],
user["coverArtRole"],
user["commentRole"],
user["podcastRole"],
user["shareRole"],
user["videoConversionRole"],
user["musicFolderId"],
user["maxBitRate"],
)
)

return users

@@ -187,7 +189,9 @@ def update_user(
:rtype: User
"""

self.api.json_request("updateUser", {
self.api.json_request(
"updateUser",
{
"username": username,
"password": password,
"email": email,
@@ -206,7 +210,8 @@ def update_user(
"videoConversionRole": video_conversion_role,
"musicFolderId": music_folder_id,
"maxBitRate": max_bit_rate,
})
},
)

updated_user = User(
self.subsonic,
1 change: 0 additions & 1 deletion tests/api/test_user_management.py
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@

import responses
from knuckles import Subsonic
from knuckles.models.user import User
from responses import Response


2 changes: 0 additions & 2 deletions tests/models/test_user.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from typing import Any

import pytest
import responses
from knuckles import Subsonic
from knuckles.exceptions import NoApiAccess
from knuckles.models.user import User
from responses import Response