From: "'Schmidt, Adriaan' via isar-users" <isar-users@googlegroups.com>
To: Anton Mikanovich <amikan@ilbers.de>,
"isar-users@googlegroups.com" <isar-users@googlegroups.com>
Subject: RE: [PATCH 1/2] testsuite: Provide code style documentation
Date: Mon, 15 Jul 2024 06:22:31 +0000 [thread overview]
Message-ID: <AS4PR10MB5318888EF244C17EFFE79B1EEDA12@AS4PR10MB5318.EURPRD10.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <20240712121324.2200037-2-amikan@ilbers.de>
Anton Mikanovich, Sent: Freitag, 12. Juli 2024 14:13:
> Add some recomendations for testcase creators.
Hi Anton,
Thanks for this! I like clear rules for consistent code.
Maybe one additional thing I see in the refactoring, and which could be stated explicitly:
## String formatting
Use format strings (f"The value is {x}") instead of printf-style formatting
("The value is %d" % x) or string concatenations ("The value is " + str(x)).
Plus few minor things below
>
> Signed-off-by: Anton Mikanovich <amikan@ilbers.de>
> ---
> testsuite/README.md | 45
> +++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 45 insertions(+)
>
> diff --git a/testsuite/README.md b/testsuite/README.md
> index cfcfb1bf..7cbacf99 100644
> --- a/testsuite/README.md
> +++ b/testsuite/README.md
> @@ -137,6 +137,51 @@ avocado so that isar testsuite files could be found:
> export PYTHONPATH=${PYTHONPATH}:${TESTSUITEDIR}
> ```
>
> +# Code style for testcases
> +
> +Recommended Python code style for the testcases is based on
> +[PEP8 Style Guide for Python Code](https://peps.python.org/pep-0008) with
> +several additions described below.
> +
> +## Using quotes
> +
> +Despite [PEP8](https://peps.python.org/pep-0008) doesn't have any string quote
> +usage recommendations, Isar preffered style is the following:
*preferred
> +
> + - Single quotes for data and small symbol-like strings.
> + - Double quotes for human-readable strings and string interpolation.
> +
> +## Line wrapping
> +
> +Argument lists don't fit in 79 characters line limit should be placed on the
> +new line, keeping them on the same line if possible. Otherwise every single
> +argument should be placed in separate line.
Argument lists *that don't fit in *the 79 characters...
> +
> +## Function definition spacing
> +
> +Any function and class definition should done in the following way:
should *be done
Adriaan
> +
> + - One line before and after inner functions.
> + - Two lines before and after module-level functions and classes.
> +
> +## Tools for checking code style
> +
> +To check the compliance with PEP8 standards:
> +
> +```
> +$ flake8 sample.py
> +```
> +
> +To format the code to recommended code style:
> +
> +```
> +$ black -S -l 79 sample.py
> +```
> +
> +Black use it's own [code
> style](https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html
> )
> +based on [PEP8](https://peps.python.org/pep-0008), so some options should be
> +used to set non-default style checking behaviour.
> +
> # Example of the downstream testcase
>
> See `meta-isar/test` for an example of the testcase for kas-based downstream.
> --
> 2.34.1
>
> --
> You received this message because you are subscribed to the Google Groups "isar-
> users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> isar-users+unsubscribe@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/isar-
> users/20240712121324.2200037-2-amikan%40ilbers.de.
--
You received this message because you are subscribed to the Google Groups "isar-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/isar-users/AS4PR10MB5318888EF244C17EFFE79B1EEDA12%40AS4PR10MB5318.EURPRD10.PROD.OUTLOOK.COM.
next prev parent reply other threads:[~2024-07-15 6:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-12 12:13 [PATCH 0/2] Python code style for the testsuite Anton Mikanovich
2024-07-12 12:13 ` [PATCH 1/2] testsuite: Provide code style documentation Anton Mikanovich
2024-07-15 6:22 ` 'Schmidt, Adriaan' via isar-users [this message]
2024-07-12 12:13 ` [PATCH 2/2] testsuite: Fix code style Anton Mikanovich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AS4PR10MB5318888EF244C17EFFE79B1EEDA12@AS4PR10MB5318.EURPRD10.PROD.OUTLOOK.COM \
--to=isar-users@googlegroups.com \
--cc=adriaan.schmidt@siemens.com \
--cc=amikan@ilbers.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox