Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/tensorflow/python/autograph/pyct/static_analysis/annos.py: 93%

15 statements  

« prev     ^ index     » next       coverage.py v7.4.0, created at 2024-01-03 07:57 +0000

1# Copyright 2017 The TensorFlow Authors. All Rights Reserved. 

2# 

3# Licensed under the Apache License, Version 2.0 (the "License"); 

4# you may not use this file except in compliance with the License. 

5# You may obtain a copy of the License at 

6# 

7# http://www.apache.org/licenses/LICENSE-2.0 

8# 

9# Unless required by applicable law or agreed to in writing, software 

10# distributed under the License is distributed on an "AS IS" BASIS, 

11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 

12# See the License for the specific language governing permissions and 

13# limitations under the License. 

14# ============================================================================== 

15"""Annotations used by the static analyzer.""" 

16 

17from enum import Enum 

18 

19 

20# TODO(mdan): Remove. 

21 

22 

23class NoValue(Enum): 

24 

25 def __repr__(self): # pylint: disable=invalid-repr-returned 

26 return self.name 

27 

28 

29class NodeAnno(NoValue): 

30 """Additional annotations used by the static analyzer. 

31 

32 These are in addition to the basic annotations declared in anno.py. 

33 """ 

34 

35 # Symbols 

36 # These flags are boolean. 

37 IS_LOCAL = 'Symbol is local to the function scope being analyzed.' 

38 IS_PARAM = 'Symbol is a parameter to the function being analyzed.' 

39 IS_MODIFIED_SINCE_ENTRY = ( 

40 'Symbol has been explicitly replaced in the current function scope.') 

41 

42 # Scopes 

43 # Scopes are represented by objects of type activity.Scope. 

44 ARGS_SCOPE = 'The scope for the argument list of a function call.' 

45 COND_SCOPE = 'The scope for the test node of a conditional statement.' 

46 ITERATE_SCOPE = 'The scope for the iterate assignment of a for loop.' 

47 ARGS_AND_BODY_SCOPE = ( 

48 'The scope for the main body of a function or lambda, including its' 

49 ' arguments.') 

50 BODY_SCOPE = ( 

51 'The scope for the main body of a statement (True branch for if ' 

52 'statements, main body for loops).') 

53 ORELSE_SCOPE = ( 

54 'The scope for the orelse body of a statement (False branch for if ' 

55 'statements, orelse body for loops).')