|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
3 | | -import copy |
4 | 3 | import re |
5 | 4 | import sys |
6 | 5 | import warnings |
@@ -2069,40 +2068,15 @@ def visit_Index(self, n: ast3.Index) -> Type: |
2069 | 2068 | def visit_Slice(self, n: ast3.Slice) -> Type: |
2070 | 2069 | return self.invalid_type(n, note="did you mean to use ',' instead of ':' ?") |
2071 | 2070 |
|
2072 | | - # Subscript(expr value, slice slice, expr_context ctx) # Python 3.8 and before |
2073 | 2071 | # Subscript(expr value, expr slice, expr_context ctx) # Python 3.9 and later |
2074 | 2072 | def visit_Subscript(self, n: ast3.Subscript) -> Type: |
2075 | | - if sys.version_info >= (3, 9): # Really 3.9a5 or later |
2076 | | - sliceval: Any = n.slice |
2077 | | - # Python 3.8 or earlier use a different AST structure for subscripts |
2078 | | - elif isinstance(n.slice, ast3.Index): |
2079 | | - sliceval: Any = n.slice.value |
2080 | | - elif isinstance(n.slice, ast3.Slice): |
2081 | | - sliceval = copy.deepcopy(n.slice) # so we don't mutate passed AST |
2082 | | - if getattr(sliceval, "col_offset", None) is None: |
2083 | | - # Fix column information so that we get Python 3.9+ message order |
2084 | | - sliceval.col_offset = sliceval.lower.col_offset |
2085 | | - else: |
2086 | | - assert isinstance(n.slice, ast3.ExtSlice) |
2087 | | - dims = cast(List[ast3.expr], copy.deepcopy(n.slice.dims)) |
2088 | | - for s in dims: |
2089 | | - # These fields don't actually have a col_offset attribute but we add |
2090 | | - # it manually. |
2091 | | - if getattr(s, "col_offset", None) is None: |
2092 | | - if isinstance(s, ast3.Index): |
2093 | | - s.col_offset = s.value.col_offset |
2094 | | - elif isinstance(s, ast3.Slice): |
2095 | | - assert s.lower is not None |
2096 | | - s.col_offset = s.lower.col_offset |
2097 | | - sliceval = ast3.Tuple(dims, n.ctx) |
2098 | | - |
2099 | 2073 | empty_tuple_index = False |
2100 | | - if isinstance(sliceval, ast3.Tuple): |
2101 | | - params = self.translate_expr_list(sliceval.elts) |
2102 | | - if len(sliceval.elts) == 0: |
| 2074 | + if isinstance(n.slice, ast3.Tuple): |
| 2075 | + params = self.translate_expr_list(n.slice.elts) |
| 2076 | + if len(n.slice.elts) == 0: |
2103 | 2077 | empty_tuple_index = True |
2104 | 2078 | else: |
2105 | | - params = [self.visit(sliceval)] |
| 2079 | + params = [self.visit(n.slice)] |
2106 | 2080 |
|
2107 | 2081 | value = self.visit(n.value) |
2108 | 2082 | if isinstance(value, UnboundType) and not value.args: |
|
0 commit comments