Avoid parenthesizing multiline strings in binary expressions (#6973)

This commit is contained in:
Micha Reiser 2023-08-30 16:03:17 +02:00 committed by GitHub
parent e2b2b1759f
commit eb552da8a9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 315 additions and 40 deletions

View file

@ -222,3 +222,94 @@ x = (
x = (
() - () #
)
# Avoid unnecessary parentheses around multiline strings.
expected_content = """<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap><loc>%s/simple/sitemap-simple.xml</loc><lastmod>%s</lastmod>
</sitemap>
</sitemapindex>
""" % (
self.base_url,
date.today(),
)
expected_content = (
"""<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap><loc>%s/simple/sitemap-simple.xml</loc><lastmod>%s</lastmod>
</sitemap>
</sitemapindex>
"""
# Needs parentheses
% (
self.base_url,
date.today(),
)
)
expected_content = (
"""<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap><loc>%s/simple/sitemap-simple.xml</loc><lastmod>%s</lastmod>
</sitemap>
</sitemapindex>
"""
%
# Needs parentheses
(
self.base_url,
date.today(),
)
)
expected_content = """<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap><loc>%s/simple/sitemap-simple.xml</loc><lastmod>%s</lastmod>
</sitemap>
</sitemapindex>
""" + a.call.expression(
self.base_url,
date.today(),
)
expected_content = """<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap><loc>%s/simple/sitemap-simple.xml</loc><lastmod>%s</lastmod>
</sitemap>
</sitemapindex>
""" + sssssssssssssssssssssssssssssssssssssssssooooo * looooooooooooooooooooooooooooooongggggggggggg
call(arg1, arg2, """
short
""", arg3=True)
expected_content = (
"""<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap><loc>%s/simple/sitemap-simple.xml</loc><lastmod>%s</lastmod>
</sitemap>
</sitemapindex>
"""
%
(
self.base_url
)
)
expected_content = (
"""<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap><loc>%s/simple/sitemap-simple.xml</loc><lastmod>%s</lastmod>
</sitemap>
</sitemapindex>
"""
%
(
# Needs parentheses
self.base_url
)
)