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
|
import sys
|
||||||
|
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
|
from typing import List
|
||||||
|
|
||||||
from diffuse import constants
|
from diffuse import constants
|
||||||
from diffuse import utils
|
from diffuse import utils
|
||||||
|
@ -386,7 +387,7 @@ class Preferences:
|
||||||
def getEncodings(self):
|
def getEncodings(self):
|
||||||
return self.encodings
|
return self.encodings
|
||||||
|
|
||||||
def _getDefaultEncodings(self) -> list[str]:
|
def _getDefaultEncodings(self) -> List[str]:
|
||||||
return self.string_prefs['encoding_auto_detect_codecs'].split()
|
return self.string_prefs['encoding_auto_detect_codecs'].split()
|
||||||
|
|
||||||
def getDefaultEncoding(self) -> str:
|
def getDefaultEncoding(self) -> str:
|
||||||
|
|
|
@ -25,7 +25,7 @@ import traceback
|
||||||
|
|
||||||
from enum import IntFlag
|
from enum import IntFlag
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
from typing import Final, Optional, TextIO
|
from typing import Final, List, Optional, TextIO
|
||||||
|
|
||||||
from diffuse import constants
|
from diffuse import constants
|
||||||
from diffuse.resources import theResources
|
from diffuse.resources import theResources
|
||||||
|
@ -106,7 +106,7 @@ def logErrorAndDialog(msg: str, parent: Gtk.Widget = None) -> None:
|
||||||
dialog.destroy()
|
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.'''
|
'''Create nested subdirectories and return the complete path.'''
|
||||||
for s in ss:
|
for s in ss:
|
||||||
p = os.path.join(p, s)
|
p = os.path.join(p, s)
|
||||||
|
@ -222,7 +222,7 @@ def strip_eol(s: str) -> str:
|
||||||
return s
|
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.'''
|
'''Returns the list of strings without line ending characters.'''
|
||||||
return [strip_eol(s) for s in ss]
|
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')))
|
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')
|
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
|
# 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
|
# split on new line characters
|
||||||
temp, i, n = [], 0, len(text)
|
temp, i, n = [], 0, len(text)
|
||||||
while i < n:
|
while i < n:
|
||||||
|
@ -273,7 +273,7 @@ def splitlines(text: str) -> list[str]:
|
||||||
|
|
||||||
|
|
||||||
# also recognize old Mac OS line endings
|
# 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()))
|
return _strip_eols(splitlines(fd.read()))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
from typing import Tuple
|
||||||
|
|
||||||
from diffuse import utils
|
from diffuse import utils
|
||||||
from diffuse.vcs.svn import Svn
|
from diffuse.vcs.svn import Svn
|
||||||
|
|
||||||
|
@ -33,7 +35,7 @@ class Svk(Svn):
|
||||||
return 'Depot Path: '
|
return 'Depot Path: '
|
||||||
|
|
||||||
@staticmethod
|
@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':
|
if len(s) < 4 or s[0] not in 'ACDMR':
|
||||||
return '', ''
|
return '', ''
|
||||||
return s[0], s[4:]
|
return s[0], s[4:]
|
||||||
|
|
|
@ -21,7 +21,7 @@ import os
|
||||||
import glob
|
import glob
|
||||||
|
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
from typing import Optional
|
from typing import Optional, Tuple
|
||||||
|
|
||||||
from diffuse import utils
|
from diffuse import utils
|
||||||
from diffuse.vcs.folder_set import FolderSet
|
from diffuse.vcs.folder_set import FolderSet
|
||||||
|
@ -44,7 +44,7 @@ class Svn(VcsInterface):
|
||||||
return 'URL: '
|
return 'URL: '
|
||||||
|
|
||||||
@staticmethod
|
@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':
|
if len(s) < 8 or s[0] not in 'ACDMR':
|
||||||
return '', ''
|
return '', ''
|
||||||
# subversion 1.6 adds a new column
|
# subversion 1.6 adds a new column
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
from typing import Optional
|
from typing import List, Optional
|
||||||
|
|
||||||
from diffuse import utils
|
from diffuse import utils
|
||||||
from diffuse.preferences import Preferences
|
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]:
|
def _get_git_repo(path: str, prefs: Preferences) -> Optional[VcsInterface]:
|
||||||
if 'GIT_DIR' in os.environ:
|
if 'GIT_DIR' in os.environ:
|
||||||
try:
|
try:
|
||||||
ss: list[str] = utils.popenReadLines(
|
ss: List[str] = utils.popenReadLines(
|
||||||
path,
|
path,
|
||||||
[
|
[
|
||||||
prefs.getString('git_bin'),
|
prefs.getString('git_bin'),
|
||||||
|
@ -185,7 +185,7 @@ def _get_svk_repo(path: str, prefs: Preferences) -> Optional[VcsInterface]:
|
||||||
try:
|
try:
|
||||||
# find working copies by parsing the config file
|
# find working copies by parsing the config file
|
||||||
with open(svkconfig, 'r', encoding='utf-8') as f:
|
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
|
projs, sep = [], os.sep
|
||||||
# find the separator character
|
# find the separator character
|
||||||
for s in ss:
|
for s in ss:
|
||||||
|
|
Loading…
Reference in New Issue