Fix up string splitting to prepare for pylint update. (#75479)

* Use rsplit with maxsplit in BaseCacheModule.
* Use maxsplit for accessing first item.
* ansible-test - More efficient splitting.
pull/75484/head
Matt Clay 3 years ago committed by GitHub
parent ce6d8a143c
commit 7450e87615
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -4,3 +4,5 @@ minor_changes:
- unicode utils - Fix ``__all__`` which was incorrectly declared as a string instead of a tuple.
- connection base - Avoid using deprecated ``@abstractproperty`` decorator.
- user module - Remove unused code.
- cache base - More efficient string splitting.
- ansible-test - More efficient string splitting.

@ -47,7 +47,7 @@ class BaseCacheModule(AnsiblePlugin):
if not hasattr(self, '_load_name'):
display.deprecated('Rather than importing custom CacheModules directly, use ansible.plugins.loader.cache_loader',
version='2.14', collection_name='ansible.builtin')
self._load_name = self.__module__.split('.')[-1]
self._load_name = self.__module__.rsplit('.', 1)[-1]
self._load_name = resource_from_fqcr(self.__module__)
super(BaseCacheModule, self).__init__()
self.set_options(var_options=args, direct=kwargs)

@ -1130,7 +1130,7 @@ class EnvironmentDescription:
versions = ['']
versions += SUPPORTED_PYTHON_VERSIONS
versions += list(set(v.split('.')[0] for v in SUPPORTED_PYTHON_VERSIONS))
versions += list(set(v.split('.', 1)[0] for v in SUPPORTED_PYTHON_VERSIONS))
version_check = os.path.join(ANSIBLE_TEST_DATA_ROOT, 'versions.py')
python_paths = dict((v, find_executable('python%s' % v, required=False)) for v in sorted(versions))

@ -173,7 +173,7 @@ class CloudBase(ABC):
def __init__(self, args): # type: (IntegrationConfig) -> None
self.args = args
self.platform = self.__module__.split('.')[-1]
self.platform = self.__module__.rsplit('.', 1)[-1]
def config_callback(files): # type: (t.List[t.Tuple[str, str]]) -> None
"""Add the config file to the payload file list."""

@ -246,7 +246,7 @@ class TestTaskExecutor(unittest.TestCase):
mock_connection = MagicMock()
mock_templar = MagicMock()
action = 'namespace.netconf_suffix'
module_prefix = action.split('_')[0]
module_prefix = action.split('_', 1)[0]
te._task.action = action
handler = te._get_action_handler(mock_connection, mock_templar)
@ -281,7 +281,7 @@ class TestTaskExecutor(unittest.TestCase):
mock_connection = MagicMock()
mock_templar = MagicMock()
action = 'namespace.prefix_suffix'
module_prefix = action.split('_')[0]
module_prefix = action.split('_', 1)[0]
te._task.action = action
handler = te._get_action_handler(mock_connection, mock_templar)

Loading…
Cancel
Save