python: Replace silly uses of filter().

The test_management_commands use in particular was causing pickling
errors when the test failed, because Python 3 filter returns an
iterator, not a list.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2020-06-09 22:28:15 -07:00
committed by Anders Kaseorg
parent 5c9d56d2f7
commit d3e8af4ad2
4 changed files with 16 additions and 23 deletions

View File

@@ -497,10 +497,10 @@ def get_mobile_push_content(rendered_content: str) -> str:
return elem.text or ''
def format_as_quote(quote_text: str) -> str:
quote_text_list = filter(None, quote_text.split('\n')) # Remove empty lines
quote_text = '\n'.join(map(lambda x: "> "+x, quote_text_list))
quote_text += '\n'
return quote_text
return "".join(
f"> {line}\n" for line in quote_text.splitlines()
if line # Remove empty lines
)
def render_olist(ol: lxml.html.HtmlElement) -> str:
items = []