Skip to content

Commit 3ca940b

Browse files
committed
ruff format
1 parent f9ea4aa commit 3ca940b

File tree

10 files changed

+46
-49
lines changed

10 files changed

+46
-49
lines changed

jellyash/bundle.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ def __getitem__(self, key) -> Item:
4141
items = range(
4242
key.start or 0,
4343
key.stop or len(self.value["Items"]),
44-
key.step or 1)
44+
key.step or 1,
45+
)
4546
return [Item(self.value["Items"][k]) for k in items]
4647
return Item(self.value["Items"][key])
4748

@@ -59,4 +60,3 @@ def _get(self, handler, params=None):
5960
if set(("Items", "TotalRecordCount")) <= set(resp.keys()):
6061
return ApiResponse(resp)
6162
return resp
62-

jellyash/cli.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
def argparse_parser():
77
parser = argparse.ArgumentParser()
88
parser.add_argument(
9-
"--version", action="version", version=f"jellyash {__version__}")
9+
"--version", action="version", version=f"jellyash {__version__}"
10+
)
1011
return parser

jellyash/client.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,11 @@ def authed_client():
4242
try:
4343
auth_with_token(client)
4444
except (
45-
PermissionError, ValueError, JSONDecodeError, ConnectionError
46-
) as e:
45+
PermissionError,
46+
ValueError,
47+
JSONDecodeError,
48+
ConnectionError,
49+
) as e:
4750
print(f"{sys.argv[0]}: {e}")
4851
sys.exit(1)
4952
return client
50-

tests/conftest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,3 @@ class ClientTest(unittest.TestCase):
3333
@pytest.fixture(autouse=True)
3434
def _client(self):
3535
self.test_client = test_client(self.__class__)
36-

tests/test_client.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ def setUp(self):
2525

2626
def test_create_client(self):
2727
data = self.client.config.data
28-
self.assertEqual(data['app.name'], "jellyash")
29-
self.assertEqual(data['app.device_name'], platform.node())
30-
self.assertEqual(data['app.version'], __version__)
31-
self.assertTrue(data['auth.ssl'])
28+
self.assertEqual(data["app.name"], "jellyash")
29+
self.assertEqual(data["app.device_name"], platform.node())
30+
self.assertEqual(data["app.version"], __version__)
31+
self.assertTrue(data["auth.ssl"])
3232

3333
@pytest.mark.vcr
3434
def test_auth_with_password(self):
@@ -73,7 +73,7 @@ def test_auth_with_nonexistant_file(self):
7373

7474
def test_auth_with_state_zero(self):
7575
with tempfile.NamedTemporaryFile() as tmpfile:
76-
tmpfile.file.write(b"{\"User\": \"foo\"}\n")
76+
tmpfile.file.write(b'{"User": "foo"}\n')
7777
tmpfile.file.flush()
7878
ptf = pathlib.Path(tmpfile.name)
7979
with patch("jellyash.client.CREDENTIALS_FILE", ptf):
@@ -93,7 +93,7 @@ def capsys(self, capsys):
9393
def test_authed_client(self):
9494
with tempfile.NamedTemporaryFile() as tmpfile:
9595
credentials = self.test_client.auth.credentials.get_credentials()
96-
with open(tmpfile.name, 'w') as f:
96+
with open(tmpfile.name, "w") as f:
9797
json.dump(credentials["Servers"][0], f)
9898
ptf = pathlib.Path(tmpfile.name)
9999
with patch("jellyash.client.CREDENTIALS_FILE", ptf):
@@ -104,7 +104,7 @@ def test_authed_client(self):
104104
def test_authed_client_offline(self):
105105
with tempfile.NamedTemporaryFile() as tmpfile:
106106
credentials = self.test_client.auth.credentials.get_credentials()
107-
with open(tmpfile.name, 'w') as f:
107+
with open(tmpfile.name, "w") as f:
108108
json.dump(credentials["Servers"][0], f)
109109
ptf = pathlib.Path(tmpfile.name)
110110
with patch("jellyash.client.CREDENTIALS_FILE", ptf):
@@ -114,7 +114,7 @@ def test_authed_client_offline(self):
114114
captured = self.capsys.readouterr()
115115
self.assertEqual(
116116
captured.out, "test_offline: Failed to establish connection\n"
117-
)
117+
)
118118
self.assertEqual(captured.err, "")
119119

120120
def test_authed_client_non_existant_file(self):

tests/test_duration.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ def test_integration(self):
2525
with patch("jellyash.duration.authed_client") as client_mock:
2626
with patch(
2727
"argparse.ArgumentParser.parse_args",
28-
return_value=argparse.Namespace(show=["Foo", "Bar"])
28+
return_value=argparse.Namespace(show=["Foo", "Bar"]),
2929
):
3030
with patch(
31-
"jellyash.duration.calculate_duration") as avg_mock:
31+
"jellyash.duration.calculate_duration"
32+
) as avg_mock:
3233
average_duration()
3334
client_mock.assert_called_once()
3435
avg_mock.assert_called_once_with(
3536
client_mock(), "Foo Bar"
3637
)
37-

tests/test_nextup.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,22 @@ def capsys(self, capsys):
3131

3232
@pytest.mark.block_network
3333
def test_nextup(self):
34-
client_type = namedtuple('client', ['jellyfin'])
34+
client_type = namedtuple("client", ["jellyfin"])
3535
client = client_type(Mock())
3636
episode_dict = {
37-
'Name': 'Bar',
38-
'ParentIndexNumber': '4',
39-
'IndexNumber': '20',
40-
'SeriesName': 'Foo',
41-
}
37+
"Name": "Bar",
38+
"ParentIndexNumber": "4",
39+
"IndexNumber": "20",
40+
"SeriesName": "Foo",
41+
}
4242
client.jellyfin.get_next.return_value = [Item(episode_dict)]
4343
with patch("jellyash.nextup.authed_client", return_value=client):
4444
with patch(
4545
"argparse.ArgumentParser.parse_args",
46-
return_value=argparse.Namespace(limit=10)
46+
return_value=argparse.Namespace(limit=10),
4747
):
4848
nextup()
4949
client.jellyfin.get_next.assert_called_once_with(limit=10)
5050
captured = self.capsys.readouterr()
5151
self.assertEqual(captured.out, "Foo [4x20] Bar\n")
5252
self.assertEqual(captured.err, "")
53-

tests/test_search.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ class TestSearch(unittest.TestCase):
1212
def setUp(self):
1313
with open(self.cassette_name(self.id().split(".")[-1])) as f:
1414
result = json.load(f)
15-
client_type = namedtuple('client', ['jellyfin'])
15+
client_type = namedtuple("client", ["jellyfin"])
1616
self.client = client_type(Mock())
1717
self.client.jellyfin.search_media_items.return_value = ApiResponse(
1818
result
19-
)
19+
)
2020

2121
def test_term_not_found(self):
2222
with self.assertRaises(ValueError):
@@ -49,15 +49,14 @@ def _rerecord_mock_results(self):
4949
"test_multiple_terms_not_exact": "NCIS: ",
5050
"test_multiple_terms_exact": "Maid",
5151
"test_multiple_terms_exact_with_space": "The Blacklist",
52-
}
52+
}
5353
for test in test_cassettes:
5454
result = client.jellyfin.search_media_items(
5555
term=test_cassettes[test], media="Series"
56-
)
56+
)
5757
with open(self.cassette_name(test), "w") as f:
5858
json.dump(result._raw_value(), f)
5959

6060

6161
if __name__ == "__main__":
6262
TestSearch()._rerecord_mock_results()
63-

tests/test_token.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def test_create_token(self):
2020
server_url = "https://demo.jellyfin.org/stable"
2121
with patch(
2222
"argparse.ArgumentParser.parse_args",
23-
return_value=argparse.Namespace(server=server_url, user="demo")
23+
return_value=argparse.Namespace(server=server_url, user="demo"),
2424
):
2525
with tempfile.NamedTemporaryFile() as tmpfile:
2626
ptf = pathlib.Path(tmpfile.name)
@@ -38,4 +38,3 @@ def test_create_token(self):
3838
self.assertIn("AccessToken", credentials)
3939
self.assertIn("UserId", credentials)
4040
self.assertEqual(credentials["Name"], "Stable Demo")
41-

tests/test_unwatched.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -84,22 +84,19 @@ def test_specific_unwatched_unknown_special_season(self):
8484
@pytest.mark.block_network
8585
def test_specific_unwatched_special_season(self):
8686
# Pioneer One does not have a special season, so we need to mock it.
87-
client_type = namedtuple('client', ['jellyfin'])
87+
client_type = namedtuple("client", ["jellyfin"])
8888
client = client_type(Mock())
89-
show_dict = {
90-
"Id": 4,
91-
"Name": "Foo Bar"
92-
}
89+
show_dict = {"Id": 4, "Name": "Foo Bar"}
9390
special_dict = {
9491
"IndexNumber": 0,
9592
"ChildCount": 1,
96-
"UserData": {"UnplayedItemCount": 0}
97-
}
93+
"UserData": {"UnplayedItemCount": 0},
94+
}
9895
client.jellyfin.get_seasons.return_value = [Item(special_dict)]
9996
with patch(
10097
"jellyash.unwatched.search_single_show",
101-
return_value=Item(show_dict)
102-
):
98+
return_value=Item(show_dict),
99+
):
103100
specific_unwatched(client, "Foo Bar", 0)
104101
captured = self.capsys.readouterr()
105102
name = "Foo Bar, Specials"
@@ -118,17 +115,17 @@ def test_specific_unwatched_not_found(self):
118115
@pytest.mark.block_network
119116
def test_unwatched_season_without_show(self):
120117
with patch("jellyash.unwatched.authed_client"):
121-
with patch("argparse.ArgumentParser.parse_args",
122-
return_value=argparse.Namespace(show=[], season=3)
118+
with patch(
119+
"argparse.ArgumentParser.parse_args",
120+
return_value=argparse.Namespace(show=[], season=3),
123121
):
124122
# Sigh, parser.error will always exit.
125123
with self.assertRaises(SystemExit):
126124
unwatched()
127125
captured = self.capsys.readouterr()
128126
self.assertEqual(captured.out, "")
129127
self.assertIn(
130-
"Need to specify a show when specifiying a season",
131-
captured.err
128+
"Need to specify a show when specifiying a season", captured.err
132129
)
133130

134131

@@ -139,7 +136,7 @@ def test_unwatched_all(self):
139136
with patch("jellyash.unwatched.all_unwatched") as all_mock:
140137
with patch(
141138
"argparse.ArgumentParser.parse_args",
142-
return_value=argparse.Namespace(show=[], season=None)
139+
return_value=argparse.Namespace(show=[], season=None),
143140
):
144141
unwatched()
145142
all_mock.assert_called_once_with(client_mock())
@@ -149,10 +146,11 @@ def test_unwatched_specific(self):
149146
namespace = argparse.Namespace(show=["Foo", "Bar"], season=None)
150147
with patch("jellyash.unwatched.authed_client") as client_mock:
151148
with patch(
152-
"jellyash.unwatched.specific_unwatched") as specific_mock:
149+
"jellyash.unwatched.specific_unwatched"
150+
) as specific_mock:
153151
with patch(
154152
"argparse.ArgumentParser.parse_args",
155-
return_value=namespace
153+
return_value=namespace,
156154
):
157155
unwatched()
158156
specific_mock.assert_called_once_with(

0 commit comments

Comments
 (0)