Cleanup unhelpful alias _AST_FLAG
Also replace one direct call to `compile` with this flag with the equivalent wrapper `ast.parse`. This function can have a more precise type.
This commit is contained in:
		
							parent
							
								
									4fb9cc3bf0
								
							
						
					
					
						commit
						3e6f0f34ff
					
				| 
						 | 
					@ -5,7 +5,6 @@ import sys
 | 
				
			||||||
import textwrap
 | 
					import textwrap
 | 
				
			||||||
import tokenize
 | 
					import tokenize
 | 
				
			||||||
import warnings
 | 
					import warnings
 | 
				
			||||||
from ast import PyCF_ONLY_AST as _AST_FLAG
 | 
					 | 
				
			||||||
from bisect import bisect_right
 | 
					from bisect import bisect_right
 | 
				
			||||||
from types import FrameType
 | 
					from types import FrameType
 | 
				
			||||||
from typing import Iterator
 | 
					from typing import Iterator
 | 
				
			||||||
| 
						 | 
					@ -196,7 +195,7 @@ class Source:
 | 
				
			||||||
            newex.text = ex.text
 | 
					            newex.text = ex.text
 | 
				
			||||||
            raise newex
 | 
					            raise newex
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            if flag & _AST_FLAG:
 | 
					            if flag & ast.PyCF_ONLY_AST:
 | 
				
			||||||
                return co
 | 
					                return co
 | 
				
			||||||
            lines = [(x + "\n") for x in self.lines]
 | 
					            lines = [(x + "\n") for x in self.lines]
 | 
				
			||||||
            # Type ignored because linecache.cache is private.
 | 
					            # Type ignored because linecache.cache is private.
 | 
				
			||||||
| 
						 | 
					@ -321,7 +320,7 @@ def getstatementrange_ast(
 | 
				
			||||||
        # don't produce duplicate warnings when compiling source to find ast
 | 
					        # don't produce duplicate warnings when compiling source to find ast
 | 
				
			||||||
        with warnings.catch_warnings():
 | 
					        with warnings.catch_warnings():
 | 
				
			||||||
            warnings.simplefilter("ignore")
 | 
					            warnings.simplefilter("ignore")
 | 
				
			||||||
            astnode = compile(content, "source", "exec", _AST_FLAG)
 | 
					            astnode = ast.parse(content, "source", "exec")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    start, end = get_statement_startend2(lineno, astnode)
 | 
					    start, end = get_statement_startend2(lineno, astnode)
 | 
				
			||||||
    # we need to correct the end:
 | 
					    # we need to correct the end:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue