2018-09-11 11:51:47 -05:00
|
|
|
:orphan:
|
2018-09-07 08:57:36 -05:00
|
|
|
|
2019-07-26 08:51:09 -07:00
|
|
|
no-wildcard-import
|
|
|
|
==================
|
2017-08-01 16:18:27 -07:00
|
|
|
|
|
|
|
Using :code:`import *` is a bad habit which pollutes your namespace, hinders
|
|
|
|
debugging, and interferes with static analysis of code. For those reasons, we
|
|
|
|
do want to limit the use of :code:`import *` in the ansible code. Change our
|
|
|
|
code to import the specific names that you need instead.
|
|
|
|
|
|
|
|
Examples of unfixed code:
|
|
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
from ansible.module_utils.six import *
|
|
|
|
if isinstance(variable, string_types):
|
|
|
|
do_something(variable)
|
|
|
|
|
|
|
|
from ansible.module_utils.basic import *
|
2017-08-16 10:55:19 -07:00
|
|
|
module = AnsibleModule()
|
2017-08-01 16:18:27 -07:00
|
|
|
|
|
|
|
Examples of fixed code:
|
|
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
from ansible.module_utils import six
|
|
|
|
if isinstance(variable, six.string_types):
|
|
|
|
do_something(variable)
|
|
|
|
|
|
|
|
from ansible.module_utils.basic import AnsibleModule
|
2017-08-16 10:55:19 -07:00
|
|
|
module = AnsibleModule()
|