From 54973e8200a13dc9a386464c8eddaa2790155326 Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Wed, 26 Aug 2015 12:53:11 -0400 Subject: [PATCH] Remove flake8 ignores and wrap the longest lines to 140 char. Signed-off-by: Daniel Nephin --- compose/config/validation.py | 34 +++++++++++++++++++++++++------ compose/legacy.py | 3 ++- compose/project.py | 16 ++++++++++++--- tests/integration/cli_test.py | 4 +++- tests/integration/service_test.py | 5 ++++- tests/unit/config_test.py | 5 ++++- tests/unit/container_test.py | 10 ++++++++- tox.ini | 4 ++-- 8 files changed, 65 insertions(+), 16 deletions(-) diff --git a/compose/config/validation.py b/compose/config/validation.py index e5f195f40..0df73e3c2 100644 --- a/compose/config/validation.py +++ b/compose/config/validation.py @@ -30,7 +30,11 @@ DOCKER_CONFIG_HINTS = { VALID_NAME_CHARS = '[a-zA-Z0-9\._\-]' -@FormatChecker.cls_checks(format="ports", raises=ValidationError("Invalid port formatting, it should be '[[remote_ip:]remote_port:]port[/protocol]'")) +@FormatChecker.cls_checks( + format="ports", + raises=ValidationError( + "Invalid port formatting, it should be " + "'[[remote_ip:]remote_port:]port[/protocol]'")) def format_ports(instance): try: split_port(instance) @@ -122,9 +126,14 @@ def process_errors(errors): invalid_keys.append(get_unsupported_config_msg(service_name, invalid_config_key)) elif error.validator == 'anyOf': if 'image' in error.instance and 'build' in error.instance: - required.append("Service '{}' has both an image and build path specified. A service can either be built to image or use an existing image, not both.".format(service_name)) + required.append( + "Service '{}' has both an image and build path specified. " + "A service can either be built to image or use an existing " + "image, not both.".format(service_name)) elif 'image' not in error.instance and 'build' not in error.instance: - required.append("Service '{}' has neither an image nor a build path specified. Exactly one must be provided.".format(service_name)) + required.append( + "Service '{}' has neither an image nor a build path " + "specified. Exactly one must be provided.".format(service_name)) else: required.append(_clean_error_message(error.message)) elif error.validator == 'oneOf': @@ -143,12 +152,25 @@ def process_errors(errors): if len(error.path) > 0: config_key = " ".join(["'%s'" % k for k in error.path]) - type_errors.append("Service '{}' configuration key {} contains an invalid type, it should be {} {}".format(service_name, config_key, msg, error.validator_value)) + type_errors.append( + "Service '{}' configuration key {} contains an invalid " + "type, it should be {} {}".format( + service_name, + config_key, + msg, + error.validator_value)) else: - root_msgs.append("Service '{}' doesn\'t have any configuration options. All top level keys in your docker-compose.yml must map to a dictionary of configuration options.'".format(service_name)) + root_msgs.append( + "Service '{}' doesn\'t have any configuration options. " + "All top level keys in your docker-compose.yml must map " + "to a dictionary of configuration options.'".format(service_name)) elif error.validator == 'required': config_key = error.path[0] - required.append("Service '{}' option '{}' is invalid, {}".format(service_name, config_key, _clean_error_message(error.message))) + required.append( + "Service '{}' option '{}' is invalid, {}".format( + service_name, + config_key, + _clean_error_message(error.message))) elif error.validator == 'dependencies': dependency_key = list(error.validator_value.keys())[0] required_keys = ",".join(error.validator_value[dependency_key]) diff --git a/compose/legacy.py b/compose/legacy.py index e8f4f9573..541624178 100644 --- a/compose/legacy.py +++ b/compose/legacy.py @@ -17,7 +17,8 @@ Compose found the following containers without labels: {names_list} -As of Compose 1.3.0, containers are identified with labels instead of naming convention. If you want to continue using these containers, run: +As of Compose 1.3.0, containers are identified with labels instead of naming +convention. If you want to continue using these containers, run: $ docker-compose migrate-to-labels diff --git a/compose/project.py b/compose/project.py index 542c8785e..4e8696ba8 100644 --- a/compose/project.py +++ b/compose/project.py @@ -157,7 +157,9 @@ class Project(object): try: links.append((self.get_service(service_name), link_name)) except NoSuchService: - raise ConfigurationError('Service "%s" has a link to service "%s" which does not exist.' % (service_dict['name'], service_name)) + raise ConfigurationError( + 'Service "%s" has a link to service "%s" which does not ' + 'exist.' % (service_dict['name'], service_name)) del service_dict['links'] return links @@ -173,7 +175,11 @@ class Project(object): container = Container.from_id(self.client, volume_name) volumes_from.append(container) except APIError: - raise ConfigurationError('Service "%s" mounts volumes from "%s", which is not the name of a service or container.' % (service_dict['name'], volume_name)) + raise ConfigurationError( + 'Service "%s" mounts volumes from "%s", which is ' + 'not the name of a service or container.' % ( + service_dict['name'], + volume_name)) del service_dict['volumes_from'] return volumes_from @@ -188,7 +194,11 @@ class Project(object): try: net = Container.from_id(self.client, net_name) except APIError: - raise ConfigurationError('Service "%s" is trying to use the network of "%s", which is not the name of a service or container.' % (service_dict['name'], net_name)) + raise ConfigurationError( + 'Service "%s" is trying to use the network of "%s", ' + 'which is not the name of a service or container.' % ( + service_dict['name'], + net_name)) else: net = service_dict['net'] diff --git a/tests/integration/cli_test.py b/tests/integration/cli_test.py index 9552bf6a6..a7bc3b49a 100644 --- a/tests/integration/cli_test.py +++ b/tests/integration/cli_test.py @@ -93,7 +93,9 @@ class CLITestCase(DockerClientTestCase): def test_pull_with_digest(self, mock_logging): self.command.dispatch(['-f', 'digest.yml', 'pull'], None) mock_logging.info.assert_any_call('Pulling simple (busybox:latest)...') - mock_logging.info.assert_any_call('Pulling digest (busybox@sha256:38a203e1986cf79639cfb9b2e1d6e773de84002feea2d4eb006b52004ee8502d)...') + mock_logging.info.assert_any_call( + 'Pulling digest (busybox@' + 'sha256:38a203e1986cf79639cfb9b2e1d6e773de84002feea2d4eb006b52004ee8502d)...') @mock.patch('sys.stdout', new_callable=StringIO) def test_build_no_cache(self, mock_stdout): diff --git a/tests/integration/service_test.py b/tests/integration/service_test.py index bc9dcc692..fc634c8ca 100644 --- a/tests/integration/service_test.py +++ b/tests/integration/service_test.py @@ -804,7 +804,10 @@ class ServiceTest(DockerClientTestCase): self.assertEqual(env[k], v) def test_env_from_file_combined_with_env(self): - service = self.create_service('web', environment=['ONE=1', 'TWO=2', 'THREE=3'], env_file=['tests/fixtures/env/one.env', 'tests/fixtures/env/two.env']) + service = self.create_service( + 'web', + environment=['ONE=1', 'TWO=2', 'THREE=3'], + env_file=['tests/fixtures/env/one.env', 'tests/fixtures/env/two.env']) env = create_and_start_container(service).environment for k, v in {'ONE': '1', 'TWO': '2', 'THREE': '3', 'FOO': 'baz', 'DOO': 'dah'}.items(): self.assertEqual(env[k], v) diff --git a/tests/unit/config_test.py b/tests/unit/config_test.py index ccd5b57bf..51dac052f 100644 --- a/tests/unit/config_test.py +++ b/tests/unit/config_test.py @@ -529,7 +529,10 @@ class MemoryOptionsTest(unittest.TestCase): When you set a 'memswap_limit' it is invalid config unless you also set a mem_limit """ - expected_error_msg = "Invalid 'memswap_limit' configuration for 'foo' service: when defining 'memswap_limit' you must set 'mem_limit' as well" + expected_error_msg = ( + "Invalid 'memswap_limit' configuration for 'foo' service: when " + "defining 'memswap_limit' you must set 'mem_limit' as well" + ) with self.assertRaisesRegexp(ConfigurationError, expected_error_msg): config.load( config.ConfigDetails( diff --git a/tests/unit/container_test.py b/tests/unit/container_test.py index 1eba9f656..5637330cd 100644 --- a/tests/unit/container_test.py +++ b/tests/unit/container_test.py @@ -142,4 +142,12 @@ class GetContainerNameTestCase(unittest.TestCase): self.assertIsNone(get_container_name({})) self.assertEqual(get_container_name({'Name': 'myproject_db_1'}), 'myproject_db_1') self.assertEqual(get_container_name({'Names': ['/myproject_db_1', '/myproject_web_1/db']}), 'myproject_db_1') - self.assertEqual(get_container_name({'Names': ['/swarm-host-1/myproject_db_1', '/swarm-host-1/myproject_web_1/db']}), 'myproject_db_1') + self.assertEqual( + get_container_name({ + 'Names': [ + '/swarm-host-1/myproject_db_1', + '/swarm-host-1/myproject_web_1/db' + ] + }), + 'myproject_db_1' + ) diff --git a/tox.ini b/tox.ini index a2bd6b6b9..4b27a4e9b 100644 --- a/tox.ini +++ b/tox.ini @@ -33,6 +33,6 @@ deps = nose [flake8] -# ignore line-length for now -ignore = E501,E203 +# Allow really long lines for now +max-line-length = 140 exclude = compose/packages