Skip to content

Conversation

@Akasurde
Copy link
Member

SUMMARY
  • Advise user about f-string in Python 3.6+

Signed-off-by: Abhijeet Kasurde [email protected]

ISSUE TYPE
  • Docs Pull Request
COMPONENT NAME

docs/docsite/rst/dev_guide/developing_python_3.rst

* Advise user about f-string in Python 3.6+

Signed-off-by: Abhijeet Kasurde <[email protected]>
Comment on lines 380 to +389
b_command_line = b'ansible-playbook --become-user %s -K %s' % (user, playbook_file)
Use f-strings for Python 3.6+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

In Python 3.6 and later, f-strings (formatted string literals) are a more readable and concise way to format strings.

.. code-block:: python
b_command_line = f"ansible-playbook --become-user {user} -K {playbook_file}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not happy with these examples show constructing commands through string concatenation. This is a straight way to command injection. These must use shlex.quote() / shlex.join().

It'd be better to use something else in examples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants