Backport/2.8/59497 fix code formatting, remove unused imports (#59518)
* postgresql modules: fix by flake8 (#59497)
(cherry picked from commit fd35833554
)
* Backport of 59497: fix code formatting, remove unused imports
This commit is contained in:
parent
282cf8fd78
commit
9d32d06104
5 changed files with 10 additions and 14 deletions
|
@ -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)
|
|
@ -246,8 +246,7 @@ def db_create(cursor, db, owner, template, encoding, lc_collate, lc_ctype, conn_
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
db_info = get_db_info(cursor, db)
|
db_info = get_db_info(cursor, db)
|
||||||
if (encoding and
|
if (encoding and get_encoding_id(cursor, encoding) != db_info['encoding_id']):
|
||||||
get_encoding_id(cursor, encoding) != db_info['encoding_id']):
|
|
||||||
raise NotSupportedError(
|
raise NotSupportedError(
|
||||||
'Changing database encoding is not supported. '
|
'Changing database encoding is not supported. '
|
||||||
'Current encoding: %s' % db_info['encoding']
|
'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
|
return False
|
||||||
else:
|
else:
|
||||||
db_info = get_db_info(cursor, db)
|
db_info = get_db_info(cursor, db)
|
||||||
if (encoding and
|
if (encoding and get_encoding_id(cursor, encoding) != db_info['encoding_id']):
|
||||||
get_encoding_id(cursor, encoding) != db_info['encoding_id']):
|
|
||||||
return False
|
return False
|
||||||
elif lc_collate and lc_collate != db_info['lc_collate']:
|
elif lc_collate and lc_collate != db_info['lc_collate']:
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -149,7 +149,6 @@ from ansible.module_utils.postgres import (
|
||||||
postgres_common_argument_spec,
|
postgres_common_argument_spec,
|
||||||
)
|
)
|
||||||
from ansible.module_utils._text import to_native
|
from ansible.module_utils._text import to_native
|
||||||
from ansible.module_utils.database import pg_quote_identifier
|
|
||||||
|
|
||||||
executed_queries = []
|
executed_queries = []
|
||||||
|
|
||||||
|
|
|
@ -175,8 +175,6 @@ from ansible.module_utils.postgres import (
|
||||||
get_conn_params,
|
get_conn_params,
|
||||||
postgres_common_argument_spec,
|
postgres_common_argument_spec,
|
||||||
)
|
)
|
||||||
from ansible.module_utils._text import to_native
|
|
||||||
from ansible.module_utils.database import pg_quote_identifier
|
|
||||||
|
|
||||||
executed_queries = []
|
executed_queries = []
|
||||||
|
|
||||||
|
|
|
@ -485,21 +485,17 @@ def main():
|
||||||
columns = module.params["columns"]
|
columns = module.params["columns"]
|
||||||
|
|
||||||
# Check mutual exclusive parameters:
|
# Check mutual exclusive parameters:
|
||||||
if state == 'absent' and (truncate or newname or columns or tablespace or
|
if state == 'absent' and (truncate or newname or columns or tablespace or like or storage_params or unlogged or owner or including):
|
||||||
like or storage_params or unlogged or
|
|
||||||
owner or including):
|
|
||||||
module.fail_json(msg="%s: state=absent is mutually exclusive with: "
|
module.fail_json(msg="%s: state=absent is mutually exclusive with: "
|
||||||
"truncate, rename, columns, tablespace, "
|
"truncate, rename, columns, tablespace, "
|
||||||
"including, like, storage_params, unlogged, owner" % table)
|
"including, like, storage_params, unlogged, owner" % table)
|
||||||
|
|
||||||
if truncate and (newname or columns or like or unlogged or
|
if truncate and (newname or columns or like or unlogged or storage_params or owner or tablespace or including):
|
||||||
storage_params or owner or tablespace or including):
|
|
||||||
module.fail_json(msg="%s: truncate is mutually exclusive with: "
|
module.fail_json(msg="%s: truncate is mutually exclusive with: "
|
||||||
"rename, columns, like, unlogged, including, "
|
"rename, columns, like, unlogged, including, "
|
||||||
"storage_params, owner, tablespace" % table)
|
"storage_params, owner, tablespace" % table)
|
||||||
|
|
||||||
if newname and (columns or like or unlogged or
|
if newname and (columns or like or unlogged or storage_params or owner or tablespace or including):
|
||||||
storage_params or owner or tablespace or including):
|
|
||||||
module.fail_json(msg="%s: rename is mutually exclusive with: "
|
module.fail_json(msg="%s: rename is mutually exclusive with: "
|
||||||
"columns, like, unlogged, including, "
|
"columns, like, unlogged, including, "
|
||||||
"storage_params, owner, tablespace" % table)
|
"storage_params, owner, tablespace" % table)
|
||||||
|
|
Loading…
Reference in a new issue