1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/docs/docsite/rst/dev_guide/testing/sanity/no-wildcard-import.rst
Toshio Kuratomi f4d7b9a596 code-smell test changes
* Create get_exception and wildcard import code-smell tests
* Add more detail to boilerplate and no-basestring descriptions
* Remove the no-list-cmp test as the pylint undefined-variable test covers it
2017-08-03 13:15:12 -07:00

29 lines
871 B
ReStructuredText

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([...])