annotate mercurial/utils/hashutil.py @ 51861:f81e0ce5103a default tip

typing: simplify archive.gz writing and drop a few pytype suppressions I was waiting until 3.8 to use `Literal` to fix this, but there's also the ":" and "|" characters that are passed along here, meant only for the non-gz archive types. But manipulating what the local caller passes is silly- we know we're writing, so just open it for writing. As an added bonus, PyCharm stops flagging the call too (since it doesn't know about pytype suppression comments).
author Matt Harbison <matt_harbison@yahoo.com>
date Thu, 12 Sep 2024 12:53:00 -0400
parents 6000f5b25c9b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
44059
7126d8b8e0e6 hashutil: new package for hashing-related features
Augie Fackler <augie@google.com>
parents:
diff changeset
1 import hashlib
7126d8b8e0e6 hashutil: new package for hashing-related features
Augie Fackler <augie@google.com>
parents:
diff changeset
2
7126d8b8e0e6 hashutil: new package for hashing-related features
Augie Fackler <augie@google.com>
parents:
diff changeset
3 try:
46785
521ac0d7047f typing: disable import error warnings that are already handled
Matt Harbison <matt_harbison@yahoo.com>
parents: 44059
diff changeset
4 from ..thirdparty import sha1dc # pytype: disable=import-error
44059
7126d8b8e0e6 hashutil: new package for hashing-related features
Augie Fackler <augie@google.com>
parents:
diff changeset
5
7126d8b8e0e6 hashutil: new package for hashing-related features
Augie Fackler <augie@google.com>
parents:
diff changeset
6 sha1 = sha1dc.sha1
7126d8b8e0e6 hashutil: new package for hashing-related features
Augie Fackler <augie@google.com>
parents:
diff changeset
7 except (ImportError, AttributeError):
7126d8b8e0e6 hashutil: new package for hashing-related features
Augie Fackler <augie@google.com>
parents:
diff changeset
8 sha1 = hashlib.sha1