Ignore *only* specific feedparser and bs4 warnings (#277)

* Ignore *only* feedparser warnings

* Suppress bs4 warning as well
This commit is contained in:
Jakub Kuczys
2022-06-15 03:04:05 +02:00
committed by GitHub
parent ca645c82ea
commit ded3d47ce2
2 changed files with 17 additions and 6 deletions

View File

@@ -5,6 +5,6 @@
"description": "Read RSS feeds.", "description": "Read RSS feeds.",
"tags": ["rss"], "tags": ["rss"],
"permissions": ["embed_links"], "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." "end_user_data_statement": "This cog does not persistently store data or metadata about users."
} }

View File

@@ -1,6 +1,6 @@
import asyncio import asyncio
import aiohttp import aiohttp
from bs4 import BeautifulSoup from bs4 import BeautifulSoup, MarkupResemblesLocatorWarning
import copy import copy
import datetime import datetime
import discord import discord
@@ -9,8 +9,8 @@ import imghdr
import io import io
import logging import logging
import re import re
import shutup
import time import time
import warnings
from typing import Optional from typing import Optional
from types import MappingProxyType, SimpleNamespace from types import MappingProxyType, SimpleNamespace
from urllib.parse import urlparse 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]+") 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): 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"} 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): async def red_delete_data_for_user(self, **kwargs):
"""Nothing to delete""" """Nothing to delete"""
return return