Skip to content

Commit 65c8cb8

Browse files
committed
deprecation warnings
1 parent dd2124e commit 65c8cb8

9 files changed

Lines changed: 33 additions & 15 deletions

File tree

c2corg_api/ext/sqa_view.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def view(name, schema, metadata, selectable):
1616
# created
1717
t = Table(name, MetaData(), schema=schema)
1818

19-
for c in selectable.c:
19+
for c in selectable.subquery().c:
2020
t.append_column(Column(c.name, c.type, primary_key=c.primary_key))
2121

2222
return t

c2corg_api/markdown/toc.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
from markdown.util import code_escape
1818
from markdown.extensions.toc import (TocExtension, TocTreeprocessor,
19-
stashedHTML2text, unescape,
19+
run_postprocessors, strip_tags, unescape,
2020
unique, nest_toc_tokens,
2121
AtomicString, html)
2222

@@ -75,16 +75,17 @@ def run(self, doc):
7575

7676
# Do not override pre-existing ids
7777
if "id" not in el.attrib:
78-
innertext = unescape(stashedHTML2text(text, self.md))
78+
innertext = strip_tags(run_postprocessors(unescape(text), self.md)) # noqa: E501
7979
el.attrib["id"] = unique(self.slugify(innertext, self.sep), used_ids) # noqa: E501
8080

8181
if int(el.tag[-1]) >= self.toc_top and int(el.tag[-1]) <= self.toc_bottom: # noqa: E501
8282
toc_tokens.append({
8383
'level': int(el.tag[-1]),
8484
'id': el.attrib["id"],
85-
'name': unescape(stashedHTML2text(
86-
code_escape(el.attrib.get('data-toc-label', text)),
87-
self.md, strip_entities=False
85+
'name': strip_tags(run_postprocessors(
86+
unescape(code_escape(
87+
el.attrib.get('data-toc-label', text))),
88+
self.md
8889
))
8990
})
9091

c2corg_api/models/association.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,12 @@ def _get_load_associations_query(document, doc_types_to_load):
321321

322322
return DBSession \
323323
.query(column('id'), column('t'), column('p')) \
324-
.select_from(union(query_parents.select(), query_children.select()))
324+
.select_from(
325+
union(
326+
query_parents.select(),
327+
query_children.select()
328+
).subquery()
329+
)
325330

326331

327332
def _diff_associations(new_associations, current_associations):

c2corg_api/models/utils.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,12 @@ def int_for_range(start_id, end_id):
132132
else:
133133
return column >= start_id
134134

135-
q = session.query(
135+
subq = session.query(
136136
column,
137137
func.row_number().over(order_by=column).label('rownum')
138-
). \
139-
from_self(column)
138+
).subquery()
139+
140+
q = session.query(subq.c[column.key]).select_from(subq)
140141
if windowsize > 1:
141142
q = q.filter(sa.text("rownum %% %d=1" % windowsize))
142143

c2corg_api/tests/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,8 @@ def tearDown(self): # noqa
282282
# (including calls to commit()) is rolled back.
283283
testing.tearDown()
284284
if not keep:
285-
self.trans.rollback()
285+
if self.trans.is_active:
286+
self.trans.rollback()
286287
else:
287288
self.trans.commit()
288289
DBSession.remove()

c2corg_api/views/document_version.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ def get_neighbour_version_ids(version_id, document_id, lang):
138138
query = DBSession \
139139
.query(column('id'), column('t')) \
140140
.select_from(union(
141-
next_version.select(), previous_version.select()))
141+
next_version.select(), previous_version.select()
142+
).subquery())
142143

143144
previous_version_id = None
144145
next_version_id = None

c2corg_api/views/route.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,9 +432,12 @@ def update_all_pt_rating(waypoint_extrapolation=True):
432432
.filter(Waypoint.waypoint_type == 'access') \
433433
.subquery()
434434
# Merge all routes
435+
merged = union(
436+
parent_routes.select(), children_routes.select()
437+
).subquery()
435438
routes = DBSession \
436439
.query(Route) \
437-
.select_from(union(parent_routes.select(), children_routes.select())) \
440+
.select_from(merged) \
438441
.join(Route, Route.document_id == column('route_id')) \
439442
.all()
440443

c2corg_api/views/waypoint.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,9 +535,12 @@ def update_linked_routes_public_transportation_rating(waypoint, update_types):
535535
.filter(Association.parent_document_id == waypoint.document_id) \
536536
.subquery()
537537
# Merge all routes
538+
merged = union(
539+
parent_routes.select(), children_routes.select()
540+
).subquery()
538541
routes = DBSession \
539542
.query(Route) \
540-
.select_from(union(parent_routes.select(), children_routes.select())) \
543+
.select_from(merged) \
541544
.join(Route, Route.document_id == column('route_id')) \
542545
.all()
543546

pytest.ini

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
[pytest]
22
addopts = --cov=c2corg_api
33
filterwarnings =
4-
ignore::DeprecationWarning
4+
default
5+
ignore:pkg_resources is deprecated:DeprecationWarning
6+
ignore:Deprecated call to `pkg_resources.declare_namespace:DeprecationWarning
7+
ignore:HTTPResponse.getheaders\(\) is deprecated:DeprecationWarning

0 commit comments

Comments
 (0)