mirror of
https://github.com/certbot/certbot.git
synced 2026-08-01 16:19:13 +02:00
Update a few type ignore comments (#8767)
Some are no longer needed and other's comments are out of date.
For the changes to the acme nonce errors, `Exception` doesn't take kwargs. The error message about this our own classes isn't super helpful:
```
In [2]: BadNonce('nonce', 'error', foo='bar')
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-2-54555658ef99> in <module>
----> 1 BadNonce('nonce', 'error', foo='bar')
TypeError: __init__() got an unexpected keyword argument 'foo'
```
but if you try this on `Exception` which these classes inherit from, you get:
```
In [4]: Exception(foo='bar')
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-4-028b924f74c5> in <module>
----> 1 Exception(foo='bar')
TypeError: Exception() takes no keyword arguments
```
See https://github.com/python/typeshed/pull/2348 for more info.
* remove outdated ignores
* update locking ignore comment
* don't accept kwargs
This commit is contained in:
+4
-10
@@ -28,13 +28,8 @@ class NonceError(ClientError):
|
|||||||
|
|
||||||
class BadNonce(NonceError):
|
class BadNonce(NonceError):
|
||||||
"""Bad nonce error."""
|
"""Bad nonce error."""
|
||||||
def __init__(self, nonce, error, *args, **kwargs):
|
def __init__(self, nonce, error, *args):
|
||||||
# MyPy complains here that there is too many arguments for BaseException constructor.
|
super(BadNonce, self).__init__(*args)
|
||||||
# This is an error fixed in typeshed, see https://github.com/python/mypy/issues/4183
|
|
||||||
# The fix is included in MyPy>=0.740, but upgrading it would bring dozen of errors due to
|
|
||||||
# new types definitions. So we ignore the error until the code base is fixed to match
|
|
||||||
# with MyPy>=0.740 referential.
|
|
||||||
super(BadNonce, self).__init__(*args, **kwargs) # type: ignore
|
|
||||||
self.nonce = nonce
|
self.nonce = nonce
|
||||||
self.error = error
|
self.error = error
|
||||||
|
|
||||||
@@ -52,9 +47,8 @@ class MissingNonce(NonceError):
|
|||||||
:ivar requests.Response ~.response: HTTP Response
|
:ivar requests.Response ~.response: HTTP Response
|
||||||
|
|
||||||
"""
|
"""
|
||||||
def __init__(self, response, *args, **kwargs):
|
def __init__(self, response, *args):
|
||||||
# See comment in BadNonce constructor above for an explanation of type: ignore here.
|
super(MissingNonce, self).__init__(*args)
|
||||||
super(MissingNonce, self).__init__(*args, **kwargs) # type: ignore
|
|
||||||
self.response = response
|
self.response = response
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
|||||||
@@ -205,10 +205,9 @@ class _WindowsLockMechanism(_BaseLockMechanism):
|
|||||||
# Under Windows, filesystem.open will raise directly an EACCES error
|
# Under Windows, filesystem.open will raise directly an EACCES error
|
||||||
# if the lock file is already locked.
|
# if the lock file is already locked.
|
||||||
fd = filesystem.open(self._path, open_mode, 0o600)
|
fd = filesystem.open(self._path, open_mode, 0o600)
|
||||||
# The need for this "type: ignore" was fixed in
|
# This "type: ignore" is currently needed because msvcrt methods
|
||||||
# https://github.com/python/typeshed/pull/3607 and included in
|
# are only defined on Windows. See
|
||||||
# newer versions of mypy so it can be removed when mypy is
|
# https://github.com/python/typeshed/blob/16ae4c61201cd8b96b8b22cdfb2ab9e89ba5bcf2/stdlib/msvcrt.pyi.
|
||||||
# upgraded.
|
|
||||||
msvcrt.locking(fd, msvcrt.LK_NBLCK, 1) # type: ignore
|
msvcrt.locking(fd, msvcrt.LK_NBLCK, 1) # type: ignore
|
||||||
except (IOError, OSError) as err:
|
except (IOError, OSError) as err:
|
||||||
if fd:
|
if fd:
|
||||||
@@ -224,10 +223,9 @@ class _WindowsLockMechanism(_BaseLockMechanism):
|
|||||||
def release(self):
|
def release(self):
|
||||||
"""Release the lock."""
|
"""Release the lock."""
|
||||||
try:
|
try:
|
||||||
# The need for this "type: ignore" was fixed in
|
# This "type: ignore" is currently needed because msvcrt methods
|
||||||
# https://github.com/python/typeshed/pull/3607 and included in
|
# are only defined on Windows. See
|
||||||
# newer versions of mypy so it can be removed when mypy is
|
# https://github.com/python/typeshed/blob/16ae4c61201cd8b96b8b22cdfb2ab9e89ba5bcf2/stdlib/msvcrt.pyi.
|
||||||
# upgraded.
|
|
||||||
msvcrt.locking(self._fd, msvcrt.LK_UNLCK, 1) # type: ignore
|
msvcrt.locking(self._fd, msvcrt.LK_UNLCK, 1) # type: ignore
|
||||||
os.close(self._fd)
|
os.close(self._fd)
|
||||||
|
|
||||||
|
|||||||
@@ -301,8 +301,7 @@ def verify_signed_payload(public_key, signature, payload, signature_hash_algorit
|
|||||||
with warnings.catch_warnings():
|
with warnings.catch_warnings():
|
||||||
warnings.simplefilter("ignore")
|
warnings.simplefilter("ignore")
|
||||||
if isinstance(public_key, RSAPublicKey):
|
if isinstance(public_key, RSAPublicKey):
|
||||||
# https://github.com/python/typeshed/blob/master/third_party/2/cryptography/hazmat/primitives/asymmetric/rsa.pyi
|
verifier = public_key.verifier(
|
||||||
verifier = public_key.verifier( # type: ignore
|
|
||||||
signature, PKCS1v15(), signature_hash_algorithm
|
signature, PKCS1v15(), signature_hash_algorithm
|
||||||
)
|
)
|
||||||
verifier.update(payload)
|
verifier.update(payload)
|
||||||
|
|||||||
Reference in New Issue
Block a user