File tree Expand file tree Collapse file tree 3 files changed +18
-1
lines changed 
astroid/interpreter/_import Expand file tree Collapse file tree 3 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,10 @@ Release date: TBA
1616
1717  Closes #1735
1818
19+ * Suppress ``UserWarning`` when finding module specs.
20+ 
21+   Closes pylint-dev/pylint#7906
22+ 
1923
2024What's New in astroid 2.15.2?
2125=============================
Original file line number Diff line number Diff line change 1313import  pathlib 
1414import  sys 
1515import  types 
16+ import  warnings 
1617import  zipimport 
1718from  collections .abc  import  Iterator , Sequence 
1819from  pathlib  import  Path 
@@ -147,7 +148,9 @@ def find_module(
147148            )
148149        else :
149150            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 )
151154                if  (
152155                    spec 
153156                    and  spec .loader   # type: ignore[comparison-overlap] # noqa: E501 
Original file line number Diff line number Diff line change 77import  sys 
88import  time 
99import  unittest 
10+ import  warnings 
1011from  collections .abc  import  Iterator 
1112from  contextlib  import  contextmanager 
1213from  unittest  import  mock 
@@ -383,6 +384,15 @@ def test_raises_exception_for_empty_modname(self) -> None:
383384            self .manager .ast_from_module_name (None )
384385
385386
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+ 
386396class  BorgAstroidManagerTC (unittest .TestCase ):
387397    def  test_borg (self ) ->  None :
388398        """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