diff --git a/sphinx/builders/linkcheck.py b/sphinx/builders/linkcheck.py index 220011851df..b0fa936fec4 100644 --- a/sphinx/builders/linkcheck.py +++ b/sphinx/builders/linkcheck.py @@ -7,13 +7,13 @@ import re import socket import time +import warnings from html.parser import HTMLParser from os import path from queue import PriorityQueue, Queue from threading import Thread from typing import TYPE_CHECKING, NamedTuple, cast from urllib.parse import unquote, urlparse, urlsplit, urlunparse -import warnings from docutils import nodes from requests.exceptions import ConnectionError, HTTPError, SSLError, TooManyRedirects @@ -300,7 +300,7 @@ def __init__(self, config: Config, "reported as broken (equivalent to setting the option to `False`). " "See sphinx-doc/sphinx#11433 for details." ) - warnings.warn(deprecation_msg , RemovedInSphinx80Warning) + warnings.warn(deprecation_msg, RemovedInSphinx80Warning, stacklevel=1) super().__init__(daemon=True) diff --git a/tests/test_build_linkcheck.py b/tests/test_build_linkcheck.py index 71b230c31c1..d2a9cd64a7b 100644 --- a/tests/test_build_linkcheck.py +++ b/tests/test_build_linkcheck.py @@ -8,12 +8,12 @@ import sys import textwrap import time +import warnings import wsgiref.handlers from base64 import b64encode from os import path from queue import Queue from unittest import mock -import warnings import pytest from urllib3.poolmanager import PoolManager