From 295e822b8e65362a4dbfd223d271b6a91ba27494 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Thu, 10 Aug 2023 15:17:12 +0200 Subject: [PATCH] Ignore E721 in type(x) is bytes checks, isinstance won't work --- mcproto/connection.py | 4 ++-- mcproto/encryption.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mcproto/connection.py b/mcproto/connection.py index 325743fd..11f2b076 100644 --- a/mcproto/connection.py +++ b/mcproto/connection.py @@ -57,7 +57,7 @@ def enable_encryption(self, shared_secret: bytes) -> None: # subclass. This is needed since the cryptography library calls some C # code in the back, which relies on this being bytes. If it's not a bytes # instance, convert it. - if type(shared_secret) is not bytes: + if type(shared_secret) is not bytes: # noqa: E721 # we don't want isinstance shared_secret = bytes(shared_secret) self.encryption_enabled = True @@ -169,7 +169,7 @@ def enable_encryption(self, shared_secret: bytes) -> None: # subclass. This is needed since the cryptography library calls some C # code in the back, which relies on this being bytes. If it's not a bytes # instance, convert it. - if type(shared_secret) is not bytes: + if type(shared_secret) is not bytes: # noqa: E721 # we don't want isinstance shared_secret = bytes(shared_secret) self.encryption_enabled = True diff --git a/mcproto/encryption.py b/mcproto/encryption.py index e7b554fe..65da8c82 100644 --- a/mcproto/encryption.py +++ b/mcproto/encryption.py @@ -48,9 +48,9 @@ def encrypt_token_and_secret( # of the bytes class, not any subclass. This is needed since the cryptography # library calls some C code in the back, which relies on this being bytes. If # it's not a bytes instance, convert it. - if type(verification_token) is not bytes: + if type(verification_token) is not bytes: # noqa: E721 # we don't want isinstance verification_token = bytes(verification_token) - if type(shared_secret) is not bytes: + if type(shared_secret) is not bytes: # noqa: E721 # we don't want isinstance shared_secret = bytes(shared_secret) encrypted_token = public_key.encrypt(verification_token, PKCS1v15())