mirror of
				https://github.com/astral-sh/ruff.git
				synced 2025-10-31 03:55:09 +00:00 
			
		
		
		
	[ty] fix incorrect lazy scope narrowing (#19744)
## Summary This is a follow-up to #19321. Narrowing constraints introduced in a class scope were not applied even when they can be applied in lazy nested scopes. This PR fixes so that they are now applied. Conversely, there were cases where narrowing constraints were being applied in places where they should not, so it is also fixed. ## Test Plan Some TODOs in `narrow/conditionals/nested.md` are now work correctly.
This commit is contained in:
		
							parent
							
								
									64bcc8db2f
								
							
						
					
					
						commit
						351121c5c5
					
				
					 4 changed files with 12 additions and 5 deletions
				
			
		|  | @ -356,7 +356,9 @@ impl<'db, 'ast> SemanticIndexBuilder<'db, 'ast> { | |||
|             for nested_symbol in self.place_tables[popped_scope_id].symbols() { | ||||
|                 // For the same reason, symbols declared as nonlocal or global are not recorded.
 | ||||
|                 // Also, if the enclosing scope allows its members to be modified from elsewhere, the snapshot will not be recorded.
 | ||||
|                 if self.scopes[enclosing_scope_id].visibility().is_public() { | ||||
|                 // (In the case of class scopes, class variables can be modified from elsewhere, but this has no effect in nested scopes,
 | ||||
|                 // as class variables are not visible to them)
 | ||||
|                 if self.scopes[enclosing_scope_id].kind().is_module() { | ||||
|                     continue; | ||||
|                 } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Shunsuke Shibayama
						Shunsuke Shibayama