mirror of https://github.com/ansible/ansible.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
871 B
ReStructuredText
30 lines
871 B
ReStructuredText
7 years ago
|
Sanity Tests » no-wildcard-import
|
||
|
=================================
|
||
|
|
||
|
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 *
|
||
|
module = AnsibleModule([...])
|
||
|
|
||
|
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
|
||
|
module = AnsibleModule([...])
|