Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/pasta/base/ast_constants.py: 100%

4 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-06-07 06:12 +0000

1"""Constants relevant to ast code.""" 

2# Copyright 2021 Google LLC 

3# 

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

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

6# You may obtain a copy of the License at 

7# 

8# https://www.apache.org/licenses/LICENSE-2.0 

9# 

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

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

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

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

14# limitations under the License. 

15 

16import ast 

17 

18NODE_TYPE_TO_TOKENS = { 

19 ast.Add: ('+',), 

20 ast.And: ('and',), 

21 ast.BitAnd: ('&',), 

22 ast.BitOr: ('|',), 

23 ast.BitXor: ('^',), 

24 ast.Div: ('/',), 

25 ast.Eq: ('==',), 

26 ast.FloorDiv: ('//',), 

27 ast.Gt: ('>',), 

28 ast.GtE: ('>=',), 

29 ast.In: ('in',), 

30 ast.Invert: ('~',), 

31 ast.Is: ('is',), 

32 ast.IsNot: ('is', 'not',), 

33 ast.LShift: ('<<',), 

34 ast.Lt: ('<',), 

35 ast.LtE: ('<=',), 

36 ast.Mod: ('%',), 

37 ast.Mult: ('*',), 

38 ast.Not: ('not',), 

39 ast.NotEq: ('!=',), 

40 ast.NotIn: ('not', 'in',), 

41 ast.Or: ('or',), 

42 ast.Pow: ('**',), 

43 ast.RShift: ('>>',), 

44 ast.Sub: ('-',), 

45 ast.UAdd: ('+',), 

46 ast.USub: ('-',), 

47} 

48 

49 

50if hasattr(ast, 'MatMult'): 

51 NODE_TYPE_TO_TOKENS[ast.MatMult] = ('@',)