# HG changeset patch # User Matt Harbison # Date 1720710640 14400 # Node ID e6508d1e0b47fb5437a36e1f5fe00dc032991b9b # Parent 45ba8416afc47a751a4725aef030bd47f153d29d win32mbcs: use str for encoding value This was reported to the TortoiseHg tracker as: https://foss.heptapod.net/mercurial/tortoisehg/thg/-/issues/5980 It doesn't look like we have any tests for this extension, but the explicit type hints are enough to convince pytype that the module level `_encoding` attr is str. The `encode()` and `decode()` methods are too complex to add type hints for them. diff -r 45ba8416afc4 -r e6508d1e0b47 hgext/win32mbcs.py --- a/hgext/win32mbcs.py Fri Jul 12 15:29:35 2024 +0400 +++ b/hgext/win32mbcs.py Thu Jul 11 11:10:40 2024 -0400 @@ -73,7 +73,7 @@ default=lambda: encoding.encoding, ) -_encoding = None # see extsetup +_encoding: str = "" # see extsetup def decode(arg): @@ -129,7 +129,7 @@ except UnicodeError: raise error.Abort( _(b"[win32mbcs] filename conversion failed with %s encoding\n") - % _encoding + % encoding.strtolocal(_encoding) ) @@ -199,7 +199,7 @@ return # determine encoding for filename global _encoding - _encoding = ui.config(b'win32mbcs', b'encoding') + _encoding = encoding.strfromlocal(ui.config(b'win32mbcs', b'encoding')) # fake is only for relevant environment. if _encoding.lower() in problematic_encodings.split(): for f in funcs.split(): @@ -217,5 +217,6 @@ # extensions.loadall() is called. if '--debug' in sys.argv: ui.writenoi18n( - b"[win32mbcs] activated with encoding: %s\n" % _encoding + b"[win32mbcs] activated with encoding: %s\n" + % encoding.strtolocal(_encoding) )