Add static typing for FileDiffViewerBase.Line

This commit is contained in:
Romain Failliot 2022-01-09 16:04:05 -05:00
parent dcfb7ad80a
commit e660acdc48
1 changed files with 5 additions and 5 deletions

View File

@ -22,7 +22,7 @@ import os
import unicodedata import unicodedata
from gettext import gettext as _ from gettext import gettext as _
from typing import Any, Dict, List from typing import Any, Dict, List, Optional
from diffuse import utils from diffuse import utils
from diffuse.resources import theResources from diffuse.resources import theResources
@ -173,7 +173,7 @@ class FileDiffViewerBase(Gtk.Grid):
# class describing a single line of a pane # class describing a single line of a pane
class Line: class Line:
def __init__(self, line_number=None, text=None): def __init__(self, line_number: Optional[int] = None, text: Optional[str] = None) -> None:
# line number # line number
self.line_number = line_number self.line_number = line_number
# original text for the line # original text for the line
@ -181,13 +181,13 @@ class FileDiffViewerBase(Gtk.Grid):
# flag indicating modifications are present # flag indicating modifications are present
self.is_modified = False self.is_modified = False
# actual modified text # actual modified text
self.modified_text = None self.modified_text: Optional[str] = None
# cache used to speed up comparison of strings # cache used to speed up comparison of strings
# this should be cleared whenever the comparison preferences change # this should be cleared whenever the comparison preferences change
self.compare_string = None self.compare_string: Optional[str] = None
# returns the current text for this line # returns the current text for this line
def getText(self): def getText(self) -> Optional[str]:
if self.is_modified: if self.is_modified:
return self.modified_text return self.modified_text
return self.text return self.text