Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Context: Filter MarkupResemblesLocatorWarning from BeautifulSoup #46

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions flamingo/core/context.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import logging
import shutil
import os
import warnings

import bs4

from flamingo.core.data_model import ContentSet, AND, NOT, OR, Q, F
from flamingo.core.plugins.plugin_manager import PluginManager
Expand Down Expand Up @@ -34,6 +37,16 @@ def setup(self):
self.logger = logging.getLogger('flamingo')
self.logger.debug('setting up context')

# BS4: Filter MarkupResemblesLocatorWarning
# BS4 emits warnings when we try to parse strings that look like a
# path or url. So if we parse some content that may only contain
# something that looks like a path or url, but is a valid content,
# we would be greeted with a MarkupResemblesLocatorWarning.
warnings.filterwarnings(
"ignore",
category=bs4.MarkupResemblesLocatorWarning,
)

# setup plugins
self.plugins = PluginManager(self)
self.plugins.run_plugin_hook('setup')
Expand Down