From ff49d740249490d79b4300c0a21bbb2f191037f8 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Mon, 29 Apr 2024 08:01:57 +0700 Subject: [PATCH] Fixed deprecation warning in privacy plugin --- material/plugins/privacy/plugin.py | 6 ++++-- src/plugins/privacy/plugin.py | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/material/plugins/privacy/plugin.py b/material/plugins/privacy/plugin.py index 31638a785..5d2e9934f 100644 --- a/material/plugins/privacy/plugin.py +++ b/material/plugins/privacy/plugin.py @@ -363,8 +363,10 @@ class PrivacyPlugin(BasePlugin[PrivacyConfig]): else: self._fetch(file, config) - # Register external asset as file - self.assets.append(file) + # Register external asset as file - it might have already been + # registered, and since MkDocs 1.6, trigger a deprecation warning + if not self.assets.get_file_from_path(file.src_uri): + self.assets.append(file) # If the URL of the external asset includes a hash fragment, add it to # the returned file, e.g. for dark/light images - see https://t.ly/7b16Y diff --git a/src/plugins/privacy/plugin.py b/src/plugins/privacy/plugin.py index 31638a785..5d2e9934f 100644 --- a/src/plugins/privacy/plugin.py +++ b/src/plugins/privacy/plugin.py @@ -363,8 +363,10 @@ class PrivacyPlugin(BasePlugin[PrivacyConfig]): else: self._fetch(file, config) - # Register external asset as file - self.assets.append(file) + # Register external asset as file - it might have already been + # registered, and since MkDocs 1.6, trigger a deprecation warning + if not self.assets.get_file_from_path(file.src_uri): + self.assets.append(file) # If the URL of the external asset includes a hash fragment, add it to # the returned file, e.g. for dark/light images - see https://t.ly/7b16Y