From 028ef0a770b816d15773d67b43a75f3550307dec Mon Sep 17 00:00:00 2001 From: Malthe Borch Date: Thu, 3 Aug 2023 23:56:10 +0200 Subject: [PATCH] Fix linting issues --- src/snowflake/connector/auth/keypair.py | 4 +++- test/unit/test_auth_keypair.py | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/snowflake/connector/auth/keypair.py b/src/snowflake/connector/auth/keypair.py index 9b69f4a05..bc83d130b 100644 --- a/src/snowflake/connector/auth/keypair.py +++ b/src/snowflake/connector/auth/keypair.py @@ -127,7 +127,9 @@ def prepare( elif isinstance(self._private_key, RSAPrivateKey): private_key = self._private_key else: - raise TypeError(f"Expected bytes or RSAPrivateKey, got {type(self._private_key)}") + raise TypeError( + f"Expected bytes or RSAPrivateKey, got {type(self._private_key)}" + ) public_key_fp = self.calculate_public_key_fingerprint(private_key) diff --git a/test/unit/test_auth_keypair.py b/test/unit/test_auth_keypair.py index 26710236e..17a2e1600 100644 --- a/test/unit/test_auth_keypair.py +++ b/test/unit/test_auth_keypair.py @@ -5,7 +5,6 @@ from __future__ import annotations -from pytest import raises from unittest.mock import MagicMock, Mock, PropertyMock from cryptography.hazmat.backends import default_backend @@ -13,6 +12,7 @@ from cryptography.hazmat.primitives.asymmetric import rsa from cryptography.hazmat.primitives.asymmetric.rsa import RSAPrivateKey from cryptography.hazmat.primitives.serialization import load_der_private_key +from pytest import raises from snowflake.connector.auth import Auth from snowflake.connector.constants import OCSPMode @@ -99,8 +99,10 @@ def test_auth_keypair_bad_type(): """Simple Key Pair test using abstraction layer.""" account = "testaccount" user = "testuser" + class Bad: pass + auth_instance = AuthByKeyPair(private_key=Bad()) with raises(TypeError) as ex: auth_instance.handle_timeout( @@ -110,7 +112,7 @@ class Bad: user=user, password=None, ) - assert 'Bad' in str(ex) + assert "Bad" in str(ex) def _init_rest(application, post_requset):