File tree 3 files changed +18
-1
lines changed
astroid/interpreter/_import
3 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,10 @@ Release date: TBA
16
16
17
17
Closes #1735
18
18
19
+ * Suppress ``UserWarning`` when finding module specs.
20
+
21
+ Closes pylint-dev/pylint#7906
22
+
19
23
20
24
What's New in astroid 2.15.2?
21
25
=============================
Original file line number Diff line number Diff line change 13
13
import pathlib
14
14
import sys
15
15
import types
16
+ import warnings
16
17
import zipimport
17
18
from collections .abc import Iterator , Sequence
18
19
from pathlib import Path
@@ -147,7 +148,9 @@ def find_module(
147
148
)
148
149
else :
149
150
try :
150
- spec = importlib .util .find_spec (modname )
151
+ with warnings .catch_warnings ():
152
+ warnings .filterwarnings ("ignore" , category = UserWarning )
153
+ spec = importlib .util .find_spec (modname )
151
154
if (
152
155
spec
153
156
and spec .loader # type: ignore[comparison-overlap] # noqa: E501
Original file line number Diff line number Diff line change 7
7
import sys
8
8
import time
9
9
import unittest
10
+ import warnings
10
11
from collections .abc import Iterator
11
12
from contextlib import contextmanager
12
13
from unittest import mock
@@ -383,6 +384,15 @@ def test_raises_exception_for_empty_modname(self) -> None:
383
384
self .manager .ast_from_module_name (None )
384
385
385
386
387
+ class IsolatedAstroidManagerTest (resources .AstroidCacheSetupMixin , unittest .TestCase ):
388
+ def test_no_user_warning (self ):
389
+ mgr = manager .AstroidManager ()
390
+ with warnings .catch_warnings ():
391
+ warnings .filterwarnings ("error" , category = UserWarning )
392
+ mgr .ast_from_module_name ("setuptools" )
393
+ mgr .ast_from_module_name ("pip" )
394
+
395
+
386
396
class BorgAstroidManagerTC (unittest .TestCase ):
387
397
def test_borg (self ) -> None :
388
398
"""Test that the AstroidManager is really a borg, i.e. that two different
You can’t perform that action at this time.
0 commit comments