Skip to content

Commit

Permalink
Ignore E721 in type(x) is bytes checks, isinstance won't work
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsDrike committed Aug 10, 2023
1 parent ee33162 commit 4cdbb01
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions mcproto/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions mcproto/encryption.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit 4cdbb01

Please sign in to comment.