You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Before finalising this activity and merging the open PRs (that have passed the CI tests), I propose we converge on a few style guidelines for ShapePipe. What matters here is not necessarily the way we do things, rather that we are all doing things in the same way. This way we can continue to work on this clean up activity in a consistent way.
Here is my proposal, feel free to comment if you have a counter proposal for any of these points.
Switch from .format() to f-string syntax and explicitly concatenate strings with + operator. e.g.
my_short_str=f'This is a short string with param value {param_val}.'my_long_str= (
f'This is my long string with several parameters values {param_val1}, '+f'{param_val2}, {param_val3}, etc.'
)
Module Runner Decorator
Always explicitly include the module version in the decorator. Other options can be omitted if they use the default values. All modules should be at least 0.1 after clean up. e.g.
I was not too familiar with the brackets () to split long lines, I've more seen either backslash \ or no special character at the end of a split line. Are brackets considered more readable ?
Could you please add an example of a long logical expression ? I never know whether to put operators such as ||, &, and, at the end or beginning of a split line.
I was not too familiar with the brackets () to split long lines, I've more seen either backslash \ or no special character at the end of a split line. Are brackets considered more readable ?
It appears to be favoured by several Python style guides. I have been sticking to this lately, but I think it is very subjective whether or not it is more or less readable. I think it's probably favoured because it's easier to be consistent.
Could you please add an example of a long logical expression ? I never know whether to put operators such as ||, &, and, at the end or beginning of a split line.
OK, so in general you should be careful using bitwise logical operators like | and & and whenever possible use or and and. Anyway, you can break down a long expression like this e.g.
Activity
sfarrens commentedon Jun 17, 2021
Module Clean Up Guidelines
File Structure
For each module there should be:
<MODULE NAME>_runner.pyinshapepipe/modules<MODULE NAME>_packageinshapepipe/modulesModule Runner
The module runner file should contain:
executecommand (if relevant)<MODULE NAME>_runnerdecorated with the module runner decorator (see examples)The module runner function should contain:
executestdoutandstderrreturned by the module or simplyNone, NoneThe module runner function should NOT contain:
Module Package
The module package directory should contain:
__init__.pyfile with a descriptive docstring(One of) the python module(s) should contain:
sfarrens commentedon Jun 17, 2021
@aguinot , @martinkilbinger and @andrevitorelli here are the guidelines for the module clean up. Feel free to post comments if I missed anything important.
You should have already been notified regarding an issue I opened for you.
martinkilbinger commentedon Jul 7, 2021
Example module, that is already on the master branch: paste_cat_runner
sfarrens commentedon Jul 7, 2021
Before finalising this activity and merging the open PRs (that have passed the CI tests), I propose we converge on a few style guidelines for ShapePipe. What matters here is not necessarily the way we do things, rather that we are all doing things in the same way. This way we can continue to work on this clean up activity in a consistent way.
Here is my proposal, feel free to comment if you have a counter proposal for any of these points.
Long Lines (>79 characters)
Use
()blocks. e.g.String Concatenation
Switch from
.format()to f-string syntax and explicitly concatenate strings with+operator. e.g.Module Runner Decorator
Always explicitly include the module version in the decorator. Other options can be omitted if they use the default values. All modules should be at least
0.1after clean up. e.g.martinkilbinger commentedon Jul 7, 2021
@sfarrens, the suggested style is fine for me.
I was not too familiar with the brackets () to split long lines, I've more seen either backslash \ or no special character at the end of a split line. Are brackets considered more readable ?
Could you please add an example of a long logical expression ? I never know whether to put operators such as ||, &, and, at the end or beginning of a split line.
sfarrens commentedon Jul 7, 2021
@martinkilbinger
It appears to be favoured by several Python style guides. I have been sticking to this lately, but I think it is very subjective whether or not it is more or less readable. I think it's probably favoured because it's easier to be consistent.
OK, so in general you should be careful using bitwise logical operators like
|and&and whenever possible useorandand. Anyway, you can break down a long expression like this e.g.