|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
3 | | -import copy |
4 | 3 | import re |
5 | 4 | import sys |
6 | 5 | import warnings |
@@ -241,13 +240,6 @@ def parse( |
241 | 240 | path=fnam, |
242 | 241 | ).visit(ast) |
243 | 242 | except SyntaxError as e: |
244 | | - # alias to please mypyc |
245 | | - is_py38_or_earlier = sys.version_info < (3, 9) |
246 | | - if is_py38_or_earlier and e.filename == "<fstring>": |
247 | | - # In Python 3.8 and earlier, syntax errors in f-strings have lineno relative to the |
248 | | - # start of the f-string. This would be misleading, as mypy will report the error as the |
249 | | - # lineno within the file. |
250 | | - e.lineno = None |
251 | 243 | message = e.msg |
252 | 244 | if feature_version > sys.version_info.minor and message.startswith("invalid syntax"): |
253 | 245 | python_version_str = f"{options.python_version[0]}.{options.python_version[1]}" |
@@ -2069,40 +2061,15 @@ def visit_Index(self, n: ast3.Index) -> Type: |
2069 | 2061 | def visit_Slice(self, n: ast3.Slice) -> Type: |
2070 | 2062 | return self.invalid_type(n, note="did you mean to use ',' instead of ':' ?") |
2071 | 2063 |
|
2072 | | - # Subscript(expr value, slice slice, expr_context ctx) # Python 3.8 and before |
2073 | 2064 | # Subscript(expr value, expr slice, expr_context ctx) # Python 3.9 and later |
2074 | 2065 | 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 | 2066 | empty_tuple_index = False |
2100 | | - if isinstance(sliceval, ast3.Tuple): |
2101 | | - params = self.translate_expr_list(sliceval.elts) |
2102 | | - if len(sliceval.elts) == 0: |
| 2067 | + if isinstance(n.slice, ast3.Tuple): |
| 2068 | + params = self.translate_expr_list(n.slice.elts) |
| 2069 | + if len(n.slice.elts) == 0: |
2103 | 2070 | empty_tuple_index = True |
2104 | 2071 | else: |
2105 | | - params = [self.visit(sliceval)] |
| 2072 | + params = [self.visit(n.slice)] |
2106 | 2073 |
|
2107 | 2074 | value = self.visit(n.value) |
2108 | 2075 | if isinstance(value, UnboundType) and not value.args: |
|
0 commit comments