Commit d25d77bf authored by Matt Harbison's avatar Matt Harbison

py3: ensure `qtlib._styles` is `str`

The type hints weren't enough to convince pytype to flag these, but PyCharm did.
This re-enables the workaround for #810.  I suspect this also explains why there
were problems customizing colors via config in #5599.

--HG--
branch : stable
parent 9f779d05c0aa
......@@ -87,6 +87,12 @@ try:
except ImportError:
openflags = 0
if hglib.TYPE_CHECKING:
from typing import (
Dict,
Tuple,
)
if pycompat.ispy3:
from html import escape as htmlescape
else:
......@@ -377,7 +383,7 @@ def isDarkTheme(palette=None):
# effect programatically.
# TODO: update ui._styles instead of color._defaultstyles
_styles = pycompat.rapply(pycompat.sysstr, color._defaultstyles)
_styles = pycompat.rapply(pycompat.sysstr, color._defaultstyles) # type: Dict[str, str]
_effects = {
'bold': 'font-weight: bold',
......@@ -417,17 +423,17 @@ def configstyles(ui):
_styles.update(_thgstyles)
# allow the user to override
for status, cfgeffects in ui.configitems(b'color'):
for status, cfgeffects in ui.configitems(b'color'): # type: Tuple[bytes, bytes]
if b'.' not in status:
continue
cfgeffects = ui.configlist(b'color', status)
_styles[status] = b' '.join(cfgeffects)
_styles[pycompat.sysstr(status)] = pycompat.sysstr(b' '.join(cfgeffects))
for status, cfgeffects in ui.configitems(b'thg-color'):
for status, cfgeffects in ui.configitems(b'thg-color'): # type: Tuple[bytes, bytes]
if b'.' not in status:
continue
cfgeffects = ui.configlist(b'thg-color', status)
_styles[status] = b' '.join(cfgeffects)
_styles[pycompat.sysstr(status)] = pycompat.sysstr(b' '.join(cfgeffects))
# See https://doc.qt.io/qt-4.8/richtext-html-subset.html
# and https://www.w3.org/TR/SVG/types.html#ColorKeywords
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment