From 9a14c2405c0605006640ea9fc92516a28df91605 Mon Sep 17 00:00:00 2001 From: Dominic Evans Date: Wed, 15 May 2024 11:08:07 +0100 Subject: [PATCH] chore: fix flake8 warnings around isinstance use Also add max-line-length to setup.cfg to avoid E501 flagging existing code (and 100 is the standard default in most Python modules due to black/ruff) --- detect_secrets/plugins/artifactory.py | 2 +- detect_secrets/plugins/github_enterprise.py | 2 +- detect_secrets/plugins/ibm_cloud_iam.py | 2 +- setup.cfg | 3 +++ 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/detect_secrets/plugins/artifactory.py b/detect_secrets/plugins/artifactory.py index 8931f1ef5..f75ffaf7a 100644 --- a/detect_secrets/plugins/artifactory.py +++ b/detect_secrets/plugins/artifactory.py @@ -21,7 +21,7 @@ class ArtifactoryDetector(RegexBasedDetector): def verify(self, token, *args, **kwargs): try: - if type(token) == bytes: + if isinstance(token, bytes): token = token.decode('UTF-8') headers = {'X-JFrog-Art-API': token} response = requests.get( diff --git a/detect_secrets/plugins/github_enterprise.py b/detect_secrets/plugins/github_enterprise.py index 54fd569c0..b906c1a1f 100644 --- a/detect_secrets/plugins/github_enterprise.py +++ b/detect_secrets/plugins/github_enterprise.py @@ -77,7 +77,7 @@ def __init__(self, ghe_instance=DEFAULT_GHE_INSTANCE, *args, **kwargs): def verify(self, token, *args, **kwargs): try: - if type(token) == bytes: + if isinstance(token, bytes): token = token.decode('UTF-8') headers = {'Authorization': 'token %s' % token} response = requests.get(f'https://{self.ghe_instance}/api/v3', headers=headers) diff --git a/detect_secrets/plugins/ibm_cloud_iam.py b/detect_secrets/plugins/ibm_cloud_iam.py index ab2927d84..b7f1476a5 100644 --- a/detect_secrets/plugins/ibm_cloud_iam.py +++ b/detect_secrets/plugins/ibm_cloud_iam.py @@ -42,7 +42,7 @@ def verify(self, token, *args, **kwargs): def verify_cloud_iam_api_key(apikey): # pragma: no cover - if type(apikey) == bytes: + if isinstance(apikey, bytes): apikey = apikey.decode('UTF-8') headers = { 'Content-Type': 'application/x-www-form-urlencoded', diff --git a/setup.cfg b/setup.cfg index e1d320f0d..602807b58 100644 --- a/setup.cfg +++ b/setup.cfg @@ -4,5 +4,8 @@ description-file = README.md [wheel] universal = True +[flake8] +max-line-length = 100 + [tool:pytest] norecursedirs=tests/testing