# HG changeset patch # User Matt Harbison # Date 1720647455 14400 # Node ID f70f61a8c5bc75687fe96aad7fe391d91045e25e # Parent 138ab7c6a6ff1f902c7e6064e6fec4878af046a7 typing: restore `encoding.encoding` and `encoding.encodingmode` to bytes Somewhere between hg 3dbc7b1ecaba and hg 8e3f6b5bf720, pytype determined the signature of these fields changed from `bytes` to `Any`. Not sure why- the type of `environ` then and now is: `Union[WindowsEnviron, Dict[bytes, bytes], os._Environ[bytes]]` That said, PyCharm wasn't able to figure out the type of `environ`, and the `WindowsEnviron` class extends `MutableMapping` without specifying bytes for the key and value types in py3.9. But that's not changed in my setup, so I can't explain it. diff -r 138ab7c6a6ff -r f70f61a8c5bc mercurial/encoding.py --- a/mercurial/encoding.py Wed Jul 10 17:16:19 2024 -0400 +++ b/mercurial/encoding.py Wed Jul 10 17:37:35 2024 -0400 @@ -103,14 +103,15 @@ if pycompat.iswindows: _encodingrewrites[b'cp65001'] = b'utf-8' +encoding: bytes = b'' # help pytype avoid seeing None value try: - encoding = environ.get(b"HGENCODING") + encoding = environ.get(b"HGENCODING", b'') if not encoding: encoding = locale.getpreferredencoding().encode('ascii') or b'ascii' encoding = _encodingrewrites.get(encoding, encoding) except locale.Error: encoding = b'ascii' -encodingmode = environ.get(b"HGENCODINGMODE", b"strict") +encodingmode: bytes = environ.get(b"HGENCODINGMODE", b"strict") fallbackencoding = b'ISO-8859-1'