From ded3d47ce2bca2efb2333cc9ab185cb41e1f4b37 Mon Sep 17 00:00:00 2001 From: Jakub Kuczys <6032823+jack1142@users.noreply.github.com> Date: Wed, 15 Jun 2022 03:04:05 +0200 Subject: [PATCH] Ignore *only* specific feedparser and bs4 warnings (#277) * Ignore *only* feedparser warnings * Suppress bs4 warning as well --- rss/info.json | 2 +- rss/rss.py | 21 ++++++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/rss/info.json b/rss/info.json index 71f9b1e..b12f77d 100644 --- a/rss/info.json +++ b/rss/info.json @@ -5,6 +5,6 @@ "description": "Read RSS feeds.", "tags": ["rss"], "permissions": ["embed_links"], - "requirements": ["bs4", "feedparser>=6.0.0", "webcolors==1.3", "shutup"], + "requirements": ["bs4", "feedparser>=6.0.0", "webcolors==1.3"], "end_user_data_statement": "This cog does not persistently store data or metadata about users." } diff --git a/rss/rss.py b/rss/rss.py index 16946b4..58b0a60 100644 --- a/rss/rss.py +++ b/rss/rss.py @@ -1,6 +1,6 @@ import asyncio import aiohttp -from bs4 import BeautifulSoup +from bs4 import BeautifulSoup, MarkupResemblesLocatorWarning import copy import datetime import discord @@ -9,8 +9,8 @@ import imghdr import io import logging import re -import shutup import time +import warnings from typing import Optional from types import MappingProxyType, SimpleNamespace from urllib.parse import urlparse @@ -30,7 +30,20 @@ IPV4_RE = re.compile("\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}") IPV6_RE = re.compile("([a-f0-9:]+:+)+[a-f0-9]+") -__version__ = "1.8.2" +__version__ = "1.8.3" + +warnings.filterwarnings( + "ignore", + category=DeprecationWarning, + # Ignore the warning in feedparser module *and* our module to account for the unreleased fix of this warning: + # https://github.com/kurtmckee/feedparser/pull/278 + module=r"^(feedparser|rss)(\..+)?$", + message=( + "To avoid breaking existing software while fixing issue 310, a temporary mapping has been created from" + " `updated_parsed` to `published_parsed` if `updated_parsed` doesn't exist" + ) +) +warnings.filterwarnings("ignore", category=MarkupResemblesLocatorWarning) class RSS(commands.Cog): @@ -50,8 +63,6 @@ class RSS(commands.Cog): self._headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:83.0) Gecko/20100101 Firefox/83.0"} - shutup.please() - async def red_delete_data_for_user(self, **kwargs): """Nothing to delete""" return