mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 02:38:25 +00:00
Avoid parenthesizing multiline strings in binary expressions (#6973)
This commit is contained in:
parent
e2b2b1759f
commit
eb552da8a9
6 changed files with 315 additions and 40 deletions
|
@ -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
|
||||
)
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue