You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2021/10/23 01:26:05 UTC

[GitHub] [skywalking-python] kezhenxu94 commented on a change in pull request #171: Introduce better coding style

kezhenxu94 commented on a change in pull request #171:
URL: https://github.com/apache/skywalking-python/pull/171#discussion_r734906803



##########
File path: docs/en/contribution/CodingStyle.md
##########
@@ -0,0 +1,36 @@
+# Coding Style for SkyWalking Python
+
+## String formatting
+
+Since Python 3.5 is end of life, we fully utilize the clarity and performance boost brought by [f-strings](https://docs.python.org/3/reference/lexical_analysis.html#f-strings).
+Please do not use other styles - `+`, `%` or `.format` unless f-string is absolutely unfeasible in the context, or
+it is a logger message, which is [optimized](https://docs.python.org/3/howto/logging.html#optimization) for the `%` style
+
+Run [flynt](https://github.com/ikamensh/flynt) to convert other formats to f-string, pay **extra care** to possible corner 

Review comment:
       What about adding this to a new Makefile target, for example `fix-lint`?

##########
File path: docs/en/contribution/CodingStyle.md
##########
@@ -0,0 +1,36 @@
+# Coding Style for SkyWalking Python
+
+## String formatting
+
+Since Python 3.5 is end of life, we fully utilize the clarity and performance boost brought by [f-strings](https://docs.python.org/3/reference/lexical_analysis.html#f-strings).
+Please do not use other styles - `+`, `%` or `.format` unless f-string is absolutely unfeasible in the context, or
+it is a logger message, which is [optimized](https://docs.python.org/3/howto/logging.html#optimization) for the `%` style
+
+Run [flynt](https://github.com/ikamensh/flynt) to convert other formats to f-string, pay **extra care** to possible corner 
+cases leading to a semantically different conversion.
+
+### Quotes 
+
+As we know both single quotes and double quotes are both acceptable in Python. 
+For a better coding style, we enforce a check for using single quotes when possible.
+
+Please only use double quotes on the outside when there are inevitable single quotes inside the string, or when there
+are nest quotes.
+
+For example - 
+```python
+foo = f"I'm a string"
+bar = f"This repo is called 'skywalking-python'"
+```
+
+Run [unify](https://github.com/myint/unify) `unify -r your_target --in-place` to fix your quotes if flake8 complaints about it.

Review comment:
       What about adding this to a new Makefile target, for example `fix-lint`?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org