Skip to content

Commit 13aa156

Browse files
authored
Formatting (#6533)
* Removed unused imports * Replaced nested `if` statements by single one * Removed unnecessary `dict()` constructor around `dict` literal
1 parent 55fe1cc commit 13aa156

File tree

6 files changed

+38
-43
lines changed

6 files changed

+38
-43
lines changed

src/overrides/hooks/translations.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def on_page_markdown(markdown: str, *, page: Page, config: MkDocsConfig, files):
124124
# -----------------------------------------------------------------------------
125125

126126
# Map ISO 639-1 (languages) to ISO 3166 (countries)
127-
countries = dict({
127+
countries = {
128128
"af": "za",
129129
"az": "az",
130130
"ar": "ae",
@@ -191,4 +191,4 @@ def on_page_markdown(markdown: str, *, page: Page, config: MkDocsConfig, files):
191191
"zh": "cn",
192192
"zh-Hant": "cn",
193193
"zh-TW": "tw"
194-
})
194+
}

src/plugins/privacy/config.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import os
2222

2323
from mkdocs.config.base import Config
24-
from mkdocs.config.config_options import Deprecated, DictOfItems, Type
24+
from mkdocs.config.config_options import DictOfItems, Type
2525

2626
# -----------------------------------------------------------------------------
2727
# Classes

src/plugins/privacy/plugin.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ def on_config(self, config):
6262

6363
# Initialize collections of external assets
6464
self.assets = Files([])
65-
self.assets_expr_map = dict({
65+
self.assets_expr_map = {
6666
".css": r"url\((\s*http?[^)]+)\)",
6767
".js": r"[\"'](http[^\"']+\.(?:css|js(?:on)?))[\"']",
6868
**self.config.assets_expr_map
69-
})
69+
}
7070

7171
# Process external style sheets and scripts (run latest) - run this after
7272
# all other plugins, so they can add additional assets
@@ -537,7 +537,7 @@ def _save_to_file(self, path: str, content: str | bytes):
537537
log = logging.getLogger("mkdocs.material.privacy")
538538

539539
# Expected file extensions
540-
extensions = dict({
540+
extensions = {
541541
"application/javascript": ".js",
542542
"image/avif": ".avif",
543543
"image/gif": ".gif",
@@ -547,4 +547,4 @@ def _save_to_file(self, path: str, content: str | bytes):
547547
"image/webp": ".webp",
548548
"text/javascript": ".js",
549549
"text/css": ".css"
550-
})
550+
}

src/plugins/search/plugin.py

+29-31
Original file line numberDiff line numberDiff line change
@@ -450,16 +450,15 @@ def handle_starttag(self, tag, attrs):
450450
return
451451

452452
# Render opening tag if kept
453-
if not self.skip.intersection(self.context):
454-
if tag in self.keep:
453+
if not self.skip.intersection(self.context) and tag in self.keep:
455454

456-
# Check whether we're inside the section title
457-
data = self.section.text
458-
if self.section.el in self.context:
459-
data = self.section.title
455+
# Check whether we're inside the section title
456+
data = self.section.text
457+
if self.section.el in self.context:
458+
data = self.section.title
460459

461-
# Append to section title or text
462-
data.append(f"<{tag}>")
460+
# Append to section title or text
461+
data.append(f"<{tag}>")
463462

464463
# Called at the end of every HTML tag
465464
def handle_endtag(self, tag):
@@ -488,29 +487,28 @@ def handle_endtag(self, tag):
488487
return
489488

490489
# Render closing tag if kept
491-
if not self.skip.intersection(self.context):
492-
if tag in self.keep:
493-
494-
# Check whether we're inside the section title
495-
data = self.section.text
496-
if self.section.el in self.context:
497-
data = self.section.title
498-
499-
# Search for corresponding opening tag
500-
index = data.index(f"<{tag}>")
501-
for i in range(index + 1, len(data)):
502-
if not data[i].isspace():
503-
index = len(data)
504-
break
505-
506-
# Remove element if empty (or only whitespace)
507-
if len(data) > index:
508-
while len(data) > index:
509-
data.pop()
510-
511-
# Append to section title or text
512-
else:
513-
data.append(f"</{tag}>")
490+
if not self.skip.intersection(self.context) and tag in self.keep:
491+
492+
# Check whether we're inside the section title
493+
data = self.section.text
494+
if self.section.el in self.context:
495+
data = self.section.title
496+
497+
# Search for corresponding opening tag
498+
index = data.index(f"<{tag}>")
499+
for i in range(index + 1, len(data)):
500+
if not data[i].isspace():
501+
index = len(data)
502+
break
503+
504+
# Remove element if empty (or only whitespace)
505+
if len(data) > index:
506+
while len(data) > index:
507+
data.pop()
508+
509+
# Append to section title or text
510+
else:
511+
data.append(f"</{tag}>")
514512

515513
# Called for the text contents of each tag
516514
def handle_data(self, data):

src/plugins/social/plugin.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ def _load_font_from_google(self, name):
491491
log.addFilter(DuplicateFilter())
492492

493493
# Color palette
494-
colors = dict({
494+
colors = {
495495
"red": { "fill": "#ef5552", "text": "#ffffff" },
496496
"pink": { "fill": "#e92063", "text": "#ffffff" },
497497
"purple": { "fill": "#ab47bd", "text": "#ffffff" },
@@ -513,4 +513,4 @@ def _load_font_from_google(self, name):
513513
"blue-grey": { "fill": "#546d78", "text": "#ffffff" },
514514
"black": { "fill": "#000000", "text": "#ffffff" },
515515
"white": { "fill": "#ffffff", "text": "#000000" }
516-
})
516+
}

src/plugins/tags/config.py

-3
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,9 @@
1818
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
1919
# IN THE SOFTWARE.
2020

21-
from functools import partial
22-
from markdown.extensions.toc import slugify
2321
from mkdocs.config.config_options import Optional, Type
2422
from mkdocs.config.base import Config
2523

26-
from . import casefold
2724

2825
# -----------------------------------------------------------------------------
2926
# Classes

0 commit comments

Comments
 (0)