Skip to content

Commit

Permalink
Merge pull request #46 from SmithChart/bs4-no-more-warnings
Browse files Browse the repository at this point in the history
Context: Filter MarkupResemblesLocatorWarning from BeautifulSoup
  • Loading branch information
SmithChart authored Apr 15, 2024
2 parents 1c6edfc + 85f817a commit 030a4b4
Showing 1 changed file with 13 additions and 0 deletions.
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

0 comments on commit 030a4b4

Please sign in to comment.