-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
improvementThis issue or pull request will add new or improve existing functionalityThis issue or pull request will add new or improve existing functionalityneed infoThis issue or pull request requires further informationThis issue or pull request requires further information
Description
💡 Summary
We currently work around a perceived issue with type hinting with mypy
in:
hash-http-content/src/hash_http_content/hasher.py
Lines 33 to 44 in 36d4e52
# mypy relies on typeshed (https://github.com/python/typeshed) for | |
# stdlib type hinting, but it does not have the correct type hints for | |
# hashlib.new(). The PR I submitted to fix them | |
# (https://github.com/python/typeshed/pull/4973) was approved, but I | |
# am not sure if mypy will still have issues with the usage of this | |
# keyword in non Python 3.9 (when the usedforsecurity kwarg was added) | |
# environments. I believe the earliest I can test this will be in mypy | |
# v0.900, and I have made | |
# https://github.com/cisagov/hash-http-content/issues/3 to document | |
# the status of this workaround. | |
# hasher = hashlib.new(hash_algorithm, usedforsecurity=False) | |
hasher = getattr(hashlib, "new")(hash_algorithm, usedforsecurity=False) |
After a new version of
mypy
with type hint updates (possibly v0.900) is released, we should see if this workaround is still necessary to pass linting.
Motivation and context
Workarounds should only be used as long as there is something to work around.
Implementation notes
The preferred usage is commented out, so testing is simple as switching between the current and preferred usage.
Acceptance criteria
-
mypy
hook passes with the preferred usage in place - Code is updated
or
-
mypy
hook still fails with the preferred usage in place - Comment is updated to reflect the necessity of the workaround
Metadata
Metadata
Assignees
Labels
improvementThis issue or pull request will add new or improve existing functionalityThis issue or pull request will add new or improve existing functionalityneed infoThis issue or pull request requires further informationThis issue or pull request requires further information