fix: Python 3.8+ compatibility
Use `List` instead of `list` and `Tuple` instead of `tuple`
This commit is contained in:
parent
3a3016937c
commit
0bf760f22a
|
@ -24,6 +24,7 @@ import shlex
|
|||
import sys
|
||||
|
||||
from gettext import gettext as _
|
||||
from typing import List
|
||||
|
||||
from diffuse import constants
|
||||
from diffuse import utils
|
||||
|
@ -386,7 +387,7 @@ class Preferences:
|
|||
def getEncodings(self):
|
||||
return self.encodings
|
||||
|
||||
def _getDefaultEncodings(self) -> list[str]:
|
||||
def _getDefaultEncodings(self) -> List[str]:
|
||||
return self.string_prefs['encoding_auto_detect_codecs'].split()
|
||||
|
||||
def getDefaultEncoding(self) -> str:
|
||||
|
|
|
@ -25,7 +25,7 @@ import traceback
|
|||
|
||||
from enum import IntFlag
|
||||
from gettext import gettext as _
|
||||
from typing import Final, Optional, TextIO
|
||||
from typing import Final, List, Optional, TextIO
|
||||
|
||||
from diffuse import constants
|
||||
from diffuse.resources import theResources
|
||||
|
@ -106,7 +106,7 @@ def logErrorAndDialog(msg: str, parent: Gtk.Widget = None) -> None:
|
|||
dialog.destroy()
|
||||
|
||||
|
||||
def make_subdirs(p: str, ss: list[str]) -> str:
|
||||
def make_subdirs(p: str, ss: List[str]) -> str:
|
||||
'''Create nested subdirectories and return the complete path.'''
|
||||
for s in ss:
|
||||
p = os.path.join(p, s)
|
||||
|
@ -222,7 +222,7 @@ def strip_eol(s: str) -> str:
|
|||
return s
|
||||
|
||||
|
||||
def _strip_eols(ss: list[str]) -> list[str]:
|
||||
def _strip_eols(ss: List[str]) -> List[str]:
|
||||
'''Returns the list of strings without line ending characters.'''
|
||||
return [strip_eol(s) for s in ss]
|
||||
|
||||
|
@ -233,7 +233,7 @@ def popenReadLines(dn, cmd, prefs, bash_pref, success_results=None):
|
|||
dn, cmd, prefs, bash_pref, success_results).decode('utf-8', errors='ignore')))
|
||||
|
||||
|
||||
def readconfiglines(fd: TextIO) -> list[str]:
|
||||
def readconfiglines(fd: TextIO) -> List[str]:
|
||||
return fd.read().replace('\r', '').split('\n')
|
||||
|
||||
|
||||
|
@ -244,7 +244,7 @@ def globEscape(s: str) -> str:
|
|||
|
||||
|
||||
# split string into lines based upon DOS, Mac, and Unix line endings
|
||||
def splitlines(text: str) -> list[str]:
|
||||
def splitlines(text: str) -> List[str]:
|
||||
# split on new line characters
|
||||
temp, i, n = [], 0, len(text)
|
||||
while i < n:
|
||||
|
@ -273,7 +273,7 @@ def splitlines(text: str) -> list[str]:
|
|||
|
||||
|
||||
# also recognize old Mac OS line endings
|
||||
def readlines(fd: TextIO) -> list[str]:
|
||||
def readlines(fd: TextIO) -> List[str]:
|
||||
return _strip_eols(splitlines(fd.read()))
|
||||
|
||||
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
|
||||
import os
|
||||
|
||||
from typing import Tuple
|
||||
|
||||
from diffuse import utils
|
||||
from diffuse.vcs.svn import Svn
|
||||
|
||||
|
@ -33,7 +35,7 @@ class Svk(Svn):
|
|||
return 'Depot Path: '
|
||||
|
||||
@staticmethod
|
||||
def _parseStatusLine(s: str) -> tuple[str, str]:
|
||||
def _parseStatusLine(s: str) -> Tuple[str, str]:
|
||||
if len(s) < 4 or s[0] not in 'ACDMR':
|
||||
return '', ''
|
||||
return s[0], s[4:]
|
||||
|
|
|
@ -21,7 +21,7 @@ import os
|
|||
import glob
|
||||
|
||||
from gettext import gettext as _
|
||||
from typing import Optional
|
||||
from typing import Optional, Tuple
|
||||
|
||||
from diffuse import utils
|
||||
from diffuse.vcs.folder_set import FolderSet
|
||||
|
@ -44,7 +44,7 @@ class Svn(VcsInterface):
|
|||
return 'URL: '
|
||||
|
||||
@staticmethod
|
||||
def _parseStatusLine(s: str) -> tuple[str, str]:
|
||||
def _parseStatusLine(s: str) -> Tuple[str, str]:
|
||||
if len(s) < 8 or s[0] not in 'ACDMR':
|
||||
return '', ''
|
||||
# subversion 1.6 adds a new column
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
import os
|
||||
|
||||
from gettext import gettext as _
|
||||
from typing import Optional
|
||||
from typing import List, Optional
|
||||
|
||||
from diffuse import utils
|
||||
from diffuse.preferences import Preferences
|
||||
|
@ -99,7 +99,7 @@ def _get_darcs_repo(path: str, prefs: Preferences) -> Optional[VcsInterface]:
|
|||
def _get_git_repo(path: str, prefs: Preferences) -> Optional[VcsInterface]:
|
||||
if 'GIT_DIR' in os.environ:
|
||||
try:
|
||||
ss: list[str] = utils.popenReadLines(
|
||||
ss: List[str] = utils.popenReadLines(
|
||||
path,
|
||||
[
|
||||
prefs.getString('git_bin'),
|
||||
|
@ -185,7 +185,7 @@ def _get_svk_repo(path: str, prefs: Preferences) -> Optional[VcsInterface]:
|
|||
try:
|
||||
# find working copies by parsing the config file
|
||||
with open(svkconfig, 'r', encoding='utf-8') as f:
|
||||
ss: list[str] = utils.readlines(f)
|
||||
ss: List[str] = utils.readlines(f)
|
||||
projs, sep = [], os.sep
|
||||
# find the separator character
|
||||
for s in ss:
|
||||
|
|
Loading…
Reference in New Issue