Add type annotations to start- and end-pos attributes

These are frequently used within consuming code, so having annotations
avoids others needing to work around mypy errors from them.
This commit is contained in:
Peter Law
2021-01-03 15:57:35 +00:00
parent 14c88c1f4b
commit 0e20c33c21
4 changed files with 23 additions and 19 deletions

View File

@@ -1,5 +1,6 @@
import re
from codecs import BOM_UTF8
from typing import Tuple
from parso.python.tokenize import group
@@ -13,10 +14,10 @@ class PrefixPart:
self.type = typ
self.value = value
self.spacing = spacing
self.start_pos = start_pos
self.start_pos = start_pos # type: Tuple[int, int]
@property
def end_pos(self):
def end_pos(self) -> Tuple[int, int]:
if self.value.endswith('\n'):
return self.start_pos[0] + 1, 0
if self.value == unicode_bom: