Skip to content

Commit

Permalink
Remove blocking check. (#140)
Browse files Browse the repository at this point in the history
* Remove blocking check.

* Pylint fixes.
  • Loading branch information
tjprescott authored Mar 5, 2019
1 parent 105f0f6 commit 6b5eb5d
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 32 deletions.
6 changes: 1 addition & 5 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@
# R0401 cyclic-import
# R0205 useless-object-inheritance
# R1717 consider-using-dict-comprehension
disable=W0511,C0111,C0103,I0011,R0913,R0903,R0401,R0205,R1717

# note: This is useful but some pylint suppressions only apply to Python 2 or 3
# and we run pylint on both Python 2 and 3. e.g. You may see some no-member useless-suppression messages.
enable=useless-suppression
disable=W0511,C0111,C0103,I0011,R0913,R0903,R0401,R0205,R1717,useless-suppression

[FORMAT]
max-line-length=120
Expand Down
2 changes: 0 additions & 2 deletions knack/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ def __init__(self, dest=None, argtype=None, **kwargs):

# We'll do an early fault detection to find any instances where we have inconsistent
# set of parameters for argparse
if not self.options_list and 'required' in self.options: # pylint: disable=access-member-before-definition
raise ValueError('You can\'t specify both required and an options_list')
if not self.options.get('dest', False):
raise ValueError('Missing dest')
if not self.options_list: # pylint: disable=access-member-before-definition
Expand Down
3 changes: 1 addition & 2 deletions knack/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ def get(self, section, option, fallback=_UNSET):
except (configparser.NoSectionError, configparser.NoOptionError):
if fallback is _UNSET:
raise
else:
return fallback
return fallback

def getint(self, section, option, fallback=_UNSET):
return int(self.get(section, option, fallback))
Expand Down
5 changes: 2 additions & 3 deletions knack/testsdk/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def __init__(self, cli, command, expect_failure=False):
logger.error('Command "%s" => %d. (It did not fail as expected) Output: %s', command,
self.exit_code, self.output)
raise AssertionError('The command did not fail as it was expected.')
elif not expect_failure and self.exit_code != 0:
if not expect_failure and self.exit_code != 0:
logger.error('Command "%s" => %d. Output: %s', command, self.exit_code, self.output)
raise AssertionError('The command failed. Exit code: {}'.format(self.exit_code))

Expand Down Expand Up @@ -255,8 +255,7 @@ def _in_process_execute(self, command):
except CliExecutionError as ex:
if ex.exception:
raise ex.exception
else:
raise ex
raise ex
except Exception as ex: # pylint: disable=broad-except
self.exit_code = 1
self.output = out_buffer.getvalue()
Expand Down
10 changes: 4 additions & 6 deletions knack/testsdk/checkers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ def __call__(self, execution_result):
if actual_result:
raise JMESPathCheckAssertionError(self._query, self._expected_result, actual_result,
execution_result.output)
else:
raise JMESPathCheckAssertionError(self._query, self._expected_result, 'None',
execution_result.output)
raise JMESPathCheckAssertionError(self._query, self._expected_result, 'None',
execution_result.output)


class JMESPathCheckExists(object): # pylint: disable=too-few-public-methods
Expand Down Expand Up @@ -54,9 +53,8 @@ def __call__(self, execution_result):
if actual_result:
raise JMESPathCheckAssertionError(self._query, expected_result_format, actual_result,
execution_result.output)
else:
raise JMESPathCheckAssertionError(self._query, expected_result_format, 'None',
execution_result.output)
raise JMESPathCheckAssertionError(self._query, expected_result_format, 'None',
execution_result.output)


class NoneCheck(object): # pylint: disable=too-few-public-methods
Expand Down
4 changes: 2 additions & 2 deletions knack/testsdk/recording_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ def process_response(self, response):
if length > self._max_response_body * 1024:
response['body']['string'] = \
"!!! The response body has been omitted from the recording because it is larger " \
"than {} KB. It will be replaced with blank content of {} bytes while replay. " \
"{}{}".format(self._max_response_body, length, self.control_flag, length)
"than {max} KB. It will be replaced with blank content of {length} bytes while replay. " \
"{flag}{length}".format(max=self._max_response_body, length=length, flag=self.control_flag)

return response

Expand Down
2 changes: 1 addition & 1 deletion knack/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class CLIError(Exception):
normal operation of the CLI.
Typically due to user error and can be resolved by the user.
"""
pass
pass # pylint: disable=unnecessary-pass


class CtxTypeError(TypeError):
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ colorama==0.3.9
flake8==3.2.1
jmespath==0.9.2
mock==2.0.0
pylint==1.8.4; python_version <= '2.7'
pylint==2.1.1; python_version >= '3.5'
pylint==1.9.4; python_version <= '2.7'
pylint==2.3.1; python_version >= '3.5'
pygments==2.2.0
pyyaml==3.12
six==1.10.0
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from codecs import open
from setuptools import setup, find_packages

VERSION = '0.5.2'
VERSION = '0.5.3'

DEPENDENCIES = [
'argcomplete',
Expand Down
8 changes: 4 additions & 4 deletions tests/test_deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from knack.arguments import ArgumentsContext
from knack.commands import CLICommand, CLICommandsLoader, CommandGroup

from tests.util import TestCLI
from tests.util import DummyCLI


def example_handler(arg1, arg2=None, arg3=None):
Expand Down Expand Up @@ -73,7 +73,7 @@ def load_arguments(self, command):
type: group
short-summary: A group.
"""
self.cli_ctx = TestCLI(commands_loader_cls=DeprecationTestCommandLoader)
self.cli_ctx = DummyCLI(commands_loader_cls=DeprecationTestCommandLoader)

@redirect_io
def test_deprecate_command_group_help(self):
Expand Down Expand Up @@ -186,7 +186,7 @@ def load_arguments(self, command):
type: group
short-summary: A group.
"""
self.cli_ctx = TestCLI(commands_loader_cls=DeprecationTestCommandLoader)
self.cli_ctx = DummyCLI(commands_loader_cls=DeprecationTestCommandLoader)

@redirect_io
def test_deprecate_command_group_help_plain(self):
Expand Down Expand Up @@ -294,7 +294,7 @@ def load_arguments(self, command):
type: group
short-summary: A group.
"""
self.cli_ctx = TestCLI(commands_loader_cls=DeprecationTestCommandLoader)
self.cli_ctx = DummyCLI(commands_loader_cls=DeprecationTestCommandLoader)

@redirect_io
def test_deprecate_arguments_command_help(self):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from knack.events import EVENT_PARSER_GLOBAL_CREATE
from knack.invocation import CommandInvoker

from tests.util import MockContext, TestCLI
from tests.util import MockContext, DummyCLI

io = {}

Expand Down Expand Up @@ -199,7 +199,7 @@ def load_arguments(self, command):
text: example details
"""

self.cli_ctx = TestCLI(commands_loader_cls=HelpTestCommandLoader)
self.cli_ctx = DummyCLI(commands_loader_cls=HelpTestCommandLoader)

@redirect_io
def test_choice_list_with_ints(self):
Expand Down
4 changes: 2 additions & 2 deletions tests/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ def __init__(self):
setattr(self, 'invocation', invocation)


class TestCLI(CLI):
class DummyCLI(CLI):

def get_cli_version(self):
return '0.1.0'

def __init__(self, **kwargs):
kwargs['config_dir'] = tempfile.mkdtemp()
super(TestCLI, self).__init__(**kwargs)
super(DummyCLI, self).__init__(**kwargs)

0 comments on commit 6b5eb5d

Please sign in to comment.