From 139848efcb7a78e8577ac6c9a5b49abe97340e21 Mon Sep 17 00:00:00 2001 From: Oz N Tiram Date: Tue, 9 Apr 2019 23:24:16 +0200 Subject: [PATCH] Relax pycodestyle: import only allowed at the top While this is a really good convention, sometimes one must import stuff inside a try except block. This block is still at the top, but pycodestyle treats like it isn't, because it's in an idented block, and the outeer scope. --- kubernetes/utils/__init__.py | 4 ++-- kubernetes/utils/create_from_yaml.py | 11 +++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/kubernetes/utils/__init__.py b/kubernetes/utils/__init__.py index 91fb58633..72f55c751 100644 --- a/kubernetes/utils/__init__.py +++ b/kubernetes/utils/__init__.py @@ -14,5 +14,5 @@ from __future__ import absolute_import -from .create_from_yaml import (FailToCreateError, create_from_yaml, - create_from_dict) +from .create_from_yaml import (FailToCreateError, create_from_dict, + create_from_yaml) diff --git a/kubernetes/utils/create_from_yaml.py b/kubernetes/utils/create_from_yaml.py index 46ee53c3c..aecc3672a 100644 --- a/kubernetes/utils/create_from_yaml.py +++ b/kubernetes/utils/create_from_yaml.py @@ -13,18 +13,17 @@ # limitations under the License. import re import sys - -if sys.version_info.major < 3: - from StringIO import StringIO -else: - from io import StringIO - from os import path import yaml from kubernetes import client +if sys.version_info.major < 3: + from StringIO import StringIO # noqa: F406 +else: + from io import StringIO # noqa: F406 + def create_from_yaml( k8s_client,