Skip to content

Commit

Permalink
Merge pull request #1260 from twm/dependabot/pip/ruff-0.9.0
Browse files Browse the repository at this point in the history
Bump ruff from 0.8.3 to 0.9.0
  • Loading branch information
twm authored Jan 11, 2025
2 parents 9888d0b + 2ab7fc5 commit 91b4fa1
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 49 deletions.
2 changes: 1 addition & 1 deletion requirements_lint.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
#
# pip-compile --output-file=requirements_lint.txt requirements_lint.in
#
ruff==0.8.3
ruff==0.9.0
# via -r requirements_lint.in
2 changes: 1 addition & 1 deletion yarrharr/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ def poll(reactor, max_fetch):
raise
attempt += 1
log.debug(
("Database lock contention while persisting {count} outcomes:" " will retry (attempt {attempt})"),
("Database lock contention while persisting {count} outcomes: will retry (attempt {attempt})"),
count=len(outcomes),
attempt=attempt,
)
Expand Down
2 changes: 1 addition & 1 deletion yarrharr/management/commands/updatecounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def handle(self, *args, **options):

self.stdout.write("{:,d} feeds were audited.".format(feeds))
style = self.style.WARNING if sum(counts.values()) > 0 else self.style.SUCCESS
self.stdout.write(style(("{all:,d} all, {unread:,d} unread," " {fave:,d} fave counters were off.").format_map(counts)))
self.stdout.write(style(("{all:,d} all, {unread:,d} unread, {fave:,d} fave counters were off.").format_map(counts)))

def _audit_feed(self, feed, mutate, counts):
for name, count in (
Expand Down
2 changes: 1 addition & 1 deletion yarrharr/templatetags/ytabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def __init__(self, tab_id: str) -> None:

def render(self, context):
selected = self.tab_id in context.get("tabs_selected", ())
return f'id="{html.escape(self.tab_id)}"' f' aria-selected={"true" if selected else "false"}'
return f'id="{html.escape(self.tab_id)}" aria-selected={"true" if selected else "false"}'


register.tag("tabattrs", tabattrs)
30 changes: 18 additions & 12 deletions yarrharr/tests/test_application.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright © 2018, 2020 Tom Most <[email protected]>
# Copyright © 2018, 2020, 2025 Tom Most <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -404,7 +404,7 @@ def test_logger_namespace(self):
log.info("info\n{more}", more="info")
log.error("err")

self.assertEqual(("<6>[ns] info\n" "<6> info\n" "<3>[ns] err\n"), fout.getvalue())
self.assertEqual(("<6>[ns] info\n<6> info\n<3>[ns] err\n"), fout.getvalue())

def test_logger_namespace_failure(self):
"""
Expand All @@ -417,14 +417,14 @@ def test_logger_namespace_failure(self):
log.failure("Something went wrong", Failure(Exception("1\n2\n3")))

self.assertEqual(
(
"<2>[ns] Something went wrong\n"
"<2> Traceback (most recent call last):\n"
"<2> Failure: builtins.Exception: 1\n"
"<2> 2\n"
"<2> 3\n"
),
fout.getvalue(),
[
"<2>[ns] Something went wrong",
"<2> Traceback (most recent call last):",
"<2> Failure: builtins.Exception: 1",
"<2> 2",
"<2> 3",
],
fout.getvalue().splitlines(),
)

def test_log_legacy(self):
Expand All @@ -436,8 +436,14 @@ def test_log_legacy(self):
p.msg("m\ns\ng", logLevel=logging.DEBUG)

self.assertEqual(
("<6>[-] msg\n" "<6>[system] msg\n" "<7>[-] m\n" "<7> s\n" "<7> g\n"),
fout.getvalue(),
[
"<6>[-] msg",
"<6>[system] msg",
"<7>[-] m",
"<7> s",
"<7> g",
],
fout.getvalue().splitlines(),
)

def _get_stdlib_logger(self, name):
Expand Down
4 changes: 2 additions & 2 deletions yarrharr/tests/test_fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,7 @@ def test_persist_article_sanitize(self):
url="https://example.com/blah-blah",
date=timezone.now(),
guid="49e3c525-724c-44d8-ad0c-d78bd216d003",
raw_content="<p>Hello, <style>...</style>world" '<script type="text/javascript">alert("lololol")</script>!',
raw_content='<p>Hello, <style>...</style>world<script type="text/javascript">alert("lololol")</script>!',
),
],
etag=b'"etag"',
Expand All @@ -1001,7 +1001,7 @@ def test_persist_article_sanitize(self):
article,
raw_title="Blah &amp; Blah",
title="Blah & Blah",
raw_content=("<p>Hello, <style>...</style>world" '<script type="text/javascript">alert("lololol")</script>!'),
raw_content=('<p>Hello, <style>...</style>world<script type="text/javascript">alert("lololol")</script>!'),
content="<p>Hello, world!",
)

Expand Down
2 changes: 1 addition & 1 deletion yarrharr/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def assert_scheduled(self, expected):
self.assertEqual(
expected,
actual,
("\nNext check should be {} from" "\nnow, but found it is {} from now.").format(expected, actual),
("\nNext check should be {} from\nnow, but found it is {} from now.").format(expected, actual),
)

def test_disabled(self):
Expand Down
33 changes: 17 additions & 16 deletions yarrharr/tests/test_sanitize.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright © 2017, 2018, 2020, 2022 Tom Most <[email protected]>
# Copyright © 2017, 2018, 2020, 2022, 2025 Tom Most <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -153,25 +153,28 @@ def test_object_replaced(self):
An ``<object>`` tag is replaced with its content, omitting any
``<param>`` tags as well.
"""
html = '<object data="obsolete.swf" type="application/x-shockwave-flash">' '<param name="foo" value="bar">' "<p>Flash video</p>" "</object>"
self.assertEqual("<p>Flash video", sanitize_html(html))
html = [
'<object data="obsolete.swf" type="application/x-shockwave-flash">',
'<param name="foo" value="bar"><p>Flash video</p></object>',
]
self.assertEqual("<p>Flash video", sanitize_html("".join(html)))

def test_object_nest_replaced(self):
"""
Nested ``<object>`` tags are recursively replaced with their content.
"""
html = (
"<p>"
"<object>"
'<param name="level" value="1">'
"Level 1<br>"
"<object>"
'<param name="level" value="2">'
"Level 2"
"</object>"
"</object>"
"<p>",
"<object>",
'<param name="level" value="1">',
"Level 1<br>",
"<object>",
'<param name="level" value="2">',
"Level 2",
"</object>",
"</object>",
)
self.assertEqual("<p>Level 1<br>Level 2", sanitize_html(html))
self.assertEqual("<p>Level 1<br>Level 2", sanitize_html("".join(html)))

def test_link_tag_dropped(self):
"""
Expand Down Expand Up @@ -219,9 +222,7 @@ def test_youtube_nocookie_embed_replaced(self):
"""
A "privacy-enhanced" YouTube embed, which uses the youtube-nocookie.com domain, is replaced with a link.
"""
html = (
'<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/Q0CbN8sfihY"' ' frameborder="0" allowfullscreen></iframe>'
)
html = '<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/Q0CbN8sfihY" frameborder="0" allowfullscreen></iframe>'
self.assertEqual(
(
'<a href="https://www.youtube.com/watch?v=Q0CbN8sfihY"'
Expand Down
28 changes: 14 additions & 14 deletions yarrharr/tests/test_views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright © 2017, 2018, 2019, 2021, 2022, 2023 Tom Most <[email protected]>
# Copyright © 2017, 2018, 2019, 2021, 2022, 2023, 2025 Tom Most <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -112,26 +112,26 @@ def test_login_redirect(self):
"/label/1234/all/1234/",
"/feed/1/unread",
"/feed/2/fave/",
"/feed/3/all/4" "/feed/5/all/678/" "/labels/",
"/feed/3/all/4",
"/feed/5/all/678/",
"/labels/",
"/labels/add",
"/feeds/",
"/feeds/add/",
"/article/1234/",
]

redirects = []
for next_ in nexts:
response = c.post(
"/login/",
{
"next": next_,
"username": "james",
"password": "hunter2",
},
)
redirects.append(response["Location"])

self.assertEqual(nexts, redirects)
with self.subTest("login", next=next_):
response = c.post(
"/login/",
{
"next": next_,
"username": "james",
"password": "hunter2",
},
)
self.assertEqual(next_, response["Location"])


class LabelListTests(TestCase):
Expand Down

0 comments on commit 91b4fa1

Please sign in to comment.