From 9d32d061046dffe951bca4a3feba801d06c58cd0 Mon Sep 17 00:00:00 2001 From: Andrey Klychkov Date: Mon, 29 Jul 2019 22:27:50 +0300 Subject: [PATCH] Backport/2.8/59497 fix code formatting, remove unused imports (#59518) * postgresql modules: fix by flake8 (#59497) (cherry picked from commit fd35833554c92741d398a1715c528cf13ff60587) * Backport of 59497: fix code formatting, remove unused imports --- .../59497_postgresql-modules-remove-unused-imports.yml | 5 +++++ .../modules/database/postgresql/postgresql_db.py | 6 ++---- .../modules/database/postgresql/postgresql_ext.py | 1 - .../modules/database/postgresql/postgresql_lang.py | 2 -- .../modules/database/postgresql/postgresql_table.py | 10 +++------- 5 files changed, 10 insertions(+), 14 deletions(-) create mode 100644 changelogs/fragments/59497_postgresql-modules-remove-unused-imports.yml diff --git a/changelogs/fragments/59497_postgresql-modules-remove-unused-imports.yml b/changelogs/fragments/59497_postgresql-modules-remove-unused-imports.yml new file mode 100644 index 00000000000..f5339145123 --- /dev/null +++ b/changelogs/fragments/59497_postgresql-modules-remove-unused-imports.yml @@ -0,0 +1,5 @@ +bugfixes: +- postgresql_db.py - Fix code formatting (https://github.com/ansible/ansible/pull/59497) +- postgresql_ext.py - Remove pg_quote_identifier unused import (https://github.com/ansible/ansible/pull/59497) +- postgresql_lang.py - Remove pg_quote_identifier and to_native unused imports (https://github.com/ansible/ansible/pull/59497) +- postgresql_table.py - Fix code formatting (https://github.com/ansible/ansible/pull/59497) diff --git a/lib/ansible/modules/database/postgresql/postgresql_db.py b/lib/ansible/modules/database/postgresql/postgresql_db.py index 296d9e2d1dd..2e47c7070f3 100644 --- a/lib/ansible/modules/database/postgresql/postgresql_db.py +++ b/lib/ansible/modules/database/postgresql/postgresql_db.py @@ -246,8 +246,7 @@ def db_create(cursor, db, owner, template, encoding, lc_collate, lc_ctype, conn_ return True else: db_info = get_db_info(cursor, db) - if (encoding and - get_encoding_id(cursor, encoding) != db_info['encoding_id']): + if (encoding and get_encoding_id(cursor, encoding) != db_info['encoding_id']): raise NotSupportedError( 'Changing database encoding is not supported. ' 'Current encoding: %s' % db_info['encoding'] @@ -279,8 +278,7 @@ def db_matches(cursor, db, owner, template, encoding, lc_collate, lc_ctype, conn return False else: db_info = get_db_info(cursor, db) - if (encoding and - get_encoding_id(cursor, encoding) != db_info['encoding_id']): + if (encoding and get_encoding_id(cursor, encoding) != db_info['encoding_id']): return False elif lc_collate and lc_collate != db_info['lc_collate']: return False diff --git a/lib/ansible/modules/database/postgresql/postgresql_ext.py b/lib/ansible/modules/database/postgresql/postgresql_ext.py index f37672a2d1b..3760598f410 100644 --- a/lib/ansible/modules/database/postgresql/postgresql_ext.py +++ b/lib/ansible/modules/database/postgresql/postgresql_ext.py @@ -149,7 +149,6 @@ from ansible.module_utils.postgres import ( postgres_common_argument_spec, ) from ansible.module_utils._text import to_native -from ansible.module_utils.database import pg_quote_identifier executed_queries = [] diff --git a/lib/ansible/modules/database/postgresql/postgresql_lang.py b/lib/ansible/modules/database/postgresql/postgresql_lang.py index c601d094aa6..e9bcefbaf5a 100644 --- a/lib/ansible/modules/database/postgresql/postgresql_lang.py +++ b/lib/ansible/modules/database/postgresql/postgresql_lang.py @@ -175,8 +175,6 @@ from ansible.module_utils.postgres import ( get_conn_params, postgres_common_argument_spec, ) -from ansible.module_utils._text import to_native -from ansible.module_utils.database import pg_quote_identifier executed_queries = [] diff --git a/lib/ansible/modules/database/postgresql/postgresql_table.py b/lib/ansible/modules/database/postgresql/postgresql_table.py index 7c1e1f5bfb6..5b3b18a7ee6 100644 --- a/lib/ansible/modules/database/postgresql/postgresql_table.py +++ b/lib/ansible/modules/database/postgresql/postgresql_table.py @@ -485,21 +485,17 @@ def main(): columns = module.params["columns"] # Check mutual exclusive parameters: - if state == 'absent' and (truncate or newname or columns or tablespace or - like or storage_params or unlogged or - owner or including): + if state == 'absent' and (truncate or newname or columns or tablespace or like or storage_params or unlogged or owner or including): module.fail_json(msg="%s: state=absent is mutually exclusive with: " "truncate, rename, columns, tablespace, " "including, like, storage_params, unlogged, owner" % table) - if truncate and (newname or columns or like or unlogged or - storage_params or owner or tablespace or including): + if truncate and (newname or columns or like or unlogged or storage_params or owner or tablespace or including): module.fail_json(msg="%s: truncate is mutually exclusive with: " "rename, columns, like, unlogged, including, " "storage_params, owner, tablespace" % table) - if newname and (columns or like or unlogged or - storage_params or owner or tablespace or including): + if newname and (columns or like or unlogged or storage_params or owner or tablespace or including): module.fail_json(msg="%s: rename is mutually exclusive with: " "columns, like, unlogged, including, " "storage_params, owner, tablespace" % table)