Skip to content

Commit 71932cb

Browse files
Mention preferring one Python import per line in code style guide (#5224)
Signed-off-by: Christophe Bedard <bedard.christophe@gmail.com>
1 parent 5f01fe2 commit 71932cb

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

source/The-ROS2-Project/Contributing/Code-Style-Language-Versions.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,20 @@ We chose the following more precise rule where PEP 8 leaves some freedom:
338338
* `We allow up to 100 characters per line (fifth paragraph) <https://www.python.org/dev/peps/pep-0008/#maximum-line-length>`_.
339339
* `We pick single quotes over double quotes as long as no escaping is necessary <https://www.python.org/dev/peps/pep-0008/#string-quotes>`_.
340340
* `We prefer hanging indents for continuation lines <https://www.python.org/dev/peps/pep-0008/#indentation>`_.
341+
* `We prefer splitting having only one import per line <https://peps.python.org/pep-0008/#imports>`_:
342+
343+
.. code-block:: python
344+
345+
# This is preferred
346+
from typing import Dict
347+
from typing import List
348+
349+
# over these
350+
from typing import Dict, List
351+
from typing import (
352+
Dict,
353+
List,
354+
)
341355
342356
Tools like the ``(ament_)pycodestyle`` Python package should be used in unit-test and/or editor integration for checking Python code style.
343357

0 commit comments

Comments
 (0)