donate-cpu-server.py: Upgrade to work with Python 3 (drop Python 2 support)#2292
Conversation
|
I have thoroughly tested the server locally, but I appreciate any reviews, tests and so on. |
|
Todo: Ignore donate-cpu-server.py for pylint (Python 2) analysis. It will fail since it is Python 3 only. EDIT: This is done now |
c694964 to
34240d3
Compare
45d5f70 to
99c5826
Compare
| return datetime.datetime.now().strftime('%Y-%m-%d %H:%M') | ||
|
|
||
|
|
||
| def dateTimeFromStr(datestr): |
There was a problem hiding this comment.
How about def dateTimeFromStr(datestr: str):
There was a problem hiding this comment.
AFAIK this would require at least Python 3.5. I am not sure if everyone who develops on this script has such a recent version. Personally I like these typeinfo hints.
There was a problem hiding this comment.
AFAIK this would require at least Python 3.5. I am not sure if everyone who develops on this script has such a recent version. Personally I like these typeinfo hints.
That is not quite right. The function annotations itself are available since Python 3.0, see https://www.python.org/dev/peps/pep-3107/.
Type hints (see https://www.python.org/dev/peps/pep-0484/) are available since Python 3.5.
So it looks like it is acceptable to add function annotations like you suggested (and I also like better).
There was a problem hiding this comment.
I have added Python 3.0 function annotations instead of the comments with type hints now.
For the client script, which should be Python 2 compatible, we could use the comments with type hints. What do you think?
There was a problem hiding this comment.
yes in the client script the comments are fine.
The following commands were used for these changes: futurize -1 -w donate-cpu-server.py 2to3 -w donate-cpu-server.py
Manually fixed the Unicode issues. Received data is decoded, sent data is encoded.
This enables better static analysis and suggestions in an IDE.
donate-cpu-server.py is only Python 3 compatible, so it must be ignored for pylint verification under Python 2. All Python scripts that were verified with pylint under Python 2 are now also verified with pylint under Python 3.
Since the server script is executable now and has a shebang it can be directly executed.
99c5826 to
62205e7
Compare
danmar
left a comment
There was a problem hiding this comment.
Thanks! Feel free to merge this
No description provided.