# HG changeset patch # User Matt Harbison # Date 2021-12-15 01:13:10 # Node ID 08af0adc235cef6f81e637dc37fadc91f3208e4d # Parent 81805bba11f91f7c58a5a0ab5eff461b0ff139b4 pytype: stop excluding ssutil.py Pytype simply can't distinguish the type for this one entry's value from the other values: File "/mnt/c/Users/Matt/hg/mercurial/sslutil.py", line 142, in _hostsettings: No attribute 'append' on None [attribute-error] In Optional[Union[Any, List[nothing], bool, bytes]] File "/mnt/c/Users/Matt/hg/mercurial/sslutil.py", line 142, in _hostsettings: No attribute 'append' on bool [attribute-error] In Optional[Union[Any, List[nothing], bool, bytes]] File "/mnt/c/Users/Matt/hg/mercurial/sslutil.py", line 142, in _hostsettings: No attribute 'append' on bytes [attribute-error] In Optional[Union[Any, List[nothing], bool, bytes]] File "/mnt/c/Users/Matt/hg/mercurial/sslutil.py", line 147, in _hostsettings: No attribute 'append' on None [attribute-error] In Optional[Union[Any, List[Tuple[Any, Any]], bool, bytes]] File "/mnt/c/Users/Matt/hg/mercurial/sslutil.py", line 147, in _hostsettings: No attribute 'append' on bool [attribute-error] In Optional[Union[Any, List[Tuple[Any, Any]], bool, bytes]] File "/mnt/c/Users/Matt/hg/mercurial/sslutil.py", line 147, in _hostsettings: No attribute 'append' on bytes [attribute-error] In Optional[Union[Any, List[Tuple[Any, Any]], bool, bytes]] Differential Revision: https://phab.mercurial-scm.org/D11931 diff --git a/mercurial/sslutil.py b/mercurial/sslutil.py --- a/mercurial/sslutil.py +++ b/mercurial/sslutil.py @@ -139,12 +139,18 @@ def _hostsettings(ui, hostname): alg, fingerprint = fingerprint.split(b':', 1) fingerprint = fingerprint.replace(b':', b'').lower() + # pytype: disable=attribute-error + # `s` is heterogeneous, but this entry is always a list of tuples s[b'certfingerprints'].append((alg, fingerprint)) + # pytype: enable=attribute-error # Fingerprints from [hostfingerprints] are always SHA-1. for fingerprint in ui.configlist(b'hostfingerprints', bhostname): fingerprint = fingerprint.replace(b':', b'').lower() + # pytype: disable=attribute-error + # `s` is heterogeneous, but this entry is always a list of tuples s[b'certfingerprints'].append((b'sha1', fingerprint)) + # pytype: enable=attribute-error s[b'legacyfingerprint'] = True # If a host cert fingerprint is defined, it is the only thing that diff --git a/tests/test-check-pytype.t b/tests/test-check-pytype.t --- a/tests/test-check-pytype.t +++ b/tests/test-check-pytype.t @@ -27,7 +27,6 @@ mercurial/minirst.py # [unsuppo mercurial/pure/osutil.py # [invalid-typevar], [not-callable] mercurial/pure/parsers.py # [attribute-error] mercurial/repoview.py # [attribute-error] -mercurial/sslutil.py # [attribute-error] mercurial/testing/storage.py # tons of [attribute-error] mercurial/ui.py # [attribute-error], [wrong-arg-types] mercurial/unionrepo.py # ui, svfs, unfiltered [attribute-error] @@ -59,7 +58,6 @@ development, but may be a hinderance for > -x mercurial/pure/osutil.py \ > -x mercurial/pure/parsers.py \ > -x mercurial/repoview.py \ - > -x mercurial/sslutil.py \ > -x mercurial/testing/storage.py \ > -x mercurial/thirdparty \ > -x mercurial/ui.py \