Skip to content

Commit

Permalink
Apply ruff==0.9.0 formatting (#122)
Browse files Browse the repository at this point in the history
Automated merge of Ultralytics Code Refactor
  • Loading branch information
glenn-jocher authored Jan 10, 2025
1 parent 09f9f0c commit bbe11ba
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions plugin/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,7 @@ def parse_faq(soup):
by an `h3` tag, and its corresponding answer is captured from `p` tags until the next `h3` or `h2` tag.
"""
faqs = []
faq_section = soup.find("h2", string="FAQ")

if faq_section:
if faq_section := soup.find("h2", string="FAQ"):
current_section = faq_section.find_next_sibling()

while current_section and current_section.name != "h2":
Expand Down Expand Up @@ -287,7 +285,7 @@ def on_post_page(self, output, page, config):
if meta_description := soup.find("meta", attrs={"name": "description"}):
if self.config["add_desc"] and "description" in page.meta and (10 < len(page.meta["description"]) < 500):
if self.config["verbose"]:
print(f'File: {page.file.src_path}, Description: {page.meta["description"]}')
print(f"File: {page.file.src_path}, Description: {page.meta['description']}")
meta_description["content"] = page.meta["description"]

# Open Graph / Facebook
Expand Down Expand Up @@ -358,7 +356,7 @@ def on_post_page(self, output, page, config):
if self.config["add_authors"]:
for author in git_info["authors"]:
name, url, n, avatar = author # n is number of changes
div += f"""<a href="{url}" class="author-link" title="{name} ({n} change{'s' * (n > 1)})">
div += f"""<a href="{url}" class="author-link" title="{name} ({n} change{"s" * (n > 1)})">
<img src="{avatar}&s=96" alt="{name}" class="hover-item" loading="lazy">
</a>
"""
Expand Down Expand Up @@ -404,8 +402,7 @@ def on_post_page(self, output, page, config):
"abstract": page.meta.get("description", ""),
}

faqs = self.parse_faq(soup)
if faqs:
if faqs := self.parse_faq(soup):
ld_json_content["@type"] = ["Article", "FAQPage"]
ld_json_content["mainEntity"] = faqs

Expand Down

0 comments on commit bbe11ba

Please sign in to comment.