Skip to content

Commit c50f761

Browse files
committed
Upgrade to Ruff 0.13.0
1 parent 34b0150 commit c50f761

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+113
-105
lines changed

h/activity/bucketing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
_ = i18n.TranslationStringFactory(__package__)
1313

1414

15-
class DocumentBucket:
15+
class DocumentBucket: # noqa: PLW1641
1616
def __init__(self, document, annotations=None):
1717
self.annotations = []
1818
self.tags = set()

h/cli/commands/create_annotations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
@click.pass_context
99
@click.option("--number", default=100)
1010
def create_annotations(ctx, number):
11-
from tests.common import factories
11+
from tests.common import factories # noqa: PLC0415
1212

1313
request = ctx.obj["bootstrap"]()
1414
db = request.db

h/db/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def close_the_sqlalchemy_session(_request):
122122

123123

124124
def _maybe_create_default_organization(engine, authority): # pragma: no cover
125-
from h.services.organization import OrganizationService
125+
from h.services.organization import OrganizationService # noqa: PLC0415
126126

127127
session = Session(bind=engine)
128128
default_org = OrganizationService(session).get_default(authority)
@@ -134,8 +134,8 @@ def _maybe_create_default_organization(engine, authority): # pragma: no cover
134134

135135

136136
def _maybe_create_world_group(engine, authority, default_org): # pragma: no cover
137-
from h import models
138-
from h.models.group import ReadableBy, WriteableBy
137+
from h import models # noqa: PLC0415
138+
from h.models.group import ReadableBy, WriteableBy # noqa: PLC0415
139139

140140
session = Session(bind=engine)
141141
world_group = session.query(models.Group).filter_by(pubid="__world__").one_or_none()

h/db/types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Custom SQLAlchemy types for use with the Annotations API database.""" # noqa: A005
1+
"""Custom SQLAlchemy types for use with the Annotations API database."""
22

33
import base64
44
import binascii

h/form.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def __call__(self, template_name, **kwargs):
4949
context = self._system.copy()
5050
context.update(kwargs)
5151

52-
return Markup(template.render(context))
52+
return Markup(f"{template.render(context)}") # noqa: S704
5353

5454

5555
def create_environment(base):

h/jinja_extensions/filters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ def to_json(value):
3737
.replace("'", "\\u0027")
3838
)
3939

40-
return Markup(result)
40+
return Markup(result) # noqa: S704

h/jinja_extensions/svg_icon.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@ def svg_icon(name, css_class=""):
4848
if title_el is not None:
4949
root.remove(title_el)
5050

51-
return Markup(ElementTree.tostring(root).decode())
51+
return Markup(ElementTree.tostring(root).decode()) # noqa: S704

h/migrations/versions/58bb601c390f_fill_in_missing_denormalized_document_title.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,12 @@ def downgrade():
7171

7272

7373
def _document_title(document):
74-
for meta in document.meta_titles: # noqa: RET503
74+
for meta in document.meta_titles:
7575
if meta.value:
7676
return meta.value[0]
7777

78+
return None
79+
7880

7981
def _fetch_windows(session, chunksize=100):
8082
updated = (

h/migrations/versions/9f5e274b202c_update_all_document_web_uris.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,16 @@ class Document(Base):
3939

4040
def updated_web_uri(self):
4141
def first_http_url(type_=None):
42-
for document_uri in self.document_uris: # noqa: RET503
42+
for document_uri in self.document_uris:
4343
uri = document_uri.uri
4444
if type_ is not None and document_uri.type != type_:
4545
continue
4646
if urlparse(uri).scheme not in ["http", "https"]:
4747
continue
4848
return document_uri.uri
4949

50+
return None
51+
5052
return (
5153
first_http_url(type_="self-claim")
5254
or first_http_url(type_="rel-canonical")

h/migrations/versions/a44ef07b085a_fill_in_missing_denormalized_document_web_uri.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,13 @@ def downgrade():
6868

6969

7070
def _document_web_uri(document):
71-
for docuri in document.document_uris: # noqa: RET503
71+
for docuri in document.document_uris:
7272
uri = urlparse(docuri.uri)
7373
if uri.scheme in ["http", "https"]:
7474
return docuri.uri
7575

76+
return None
77+
7678

7779
def _fetch_windows(session, chunksize=100):
7880
updated = (

0 commit comments

Comments
 (0)