-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix some code style issues #837
Conversation
Codecov Report
|
Irony: by fixing flake8's style issues (F821 undefined name) I've added Codacy Static Code Analysis issues. FeelsBadMan |
@@ -1,4 +1,3 @@ | |||
import asyncio |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and why this was not marked as unused import before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I am seeing an unused import warning for this using flake8. It might have been in there for a long time though, like since before we added codacy?
@@ -1,5 +1,3 @@ | |||
import asyncio |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work, these are some great fixes! Looking forward to merging this.
The only ones I'm not a fan of are the conditional imports. I don't think they're needed and they're going to mess with isort as well as code coverage.
@@ -9,6 +13,9 @@ | |||
from .player_service import PlayerService | |||
from .timing import LazyIntervalTimer | |||
|
|||
if TYPE_CHECKING: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the if check is needed here. At least flake8 doesn't generate unused import warnings here. Hopefully its the same on codacy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The check is needed because of import cycle. If you remove import, then flake8 will report the undefined name error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh, then how is it possible for the type checker to import it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type checkers assume this constant (TYPE_CHECKING
) to be True
. (mypy docs)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea I know, so wouldn’t the type checker still experience an import cycle?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, type checker wouldn't experience an import cycle
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
server/gameconnection.py
Outdated
"Desync": GameConnection.handle_desync, | ||
"GameState": GameConnection.handle_game_state, | ||
"GameOption": GameConnection.handle_game_option, | ||
"GameMods": GameConnection.handle_game_mods, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nooo. This is so much worse xD
@@ -1,4 +1,3 @@ | |||
import asyncio |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I am seeing an unused import warning for this using flake8. It might have been in there for a long time though, like since before we added codacy?
@@ -1,9 +1,21 @@ | |||
from __future__ import annotations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh does this add forward references? That's pretty nice, although I'm hoping to migrate to python 3.9 soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this will become the default behavior only in python 3.10
(missing whitespace around arithmetic operator)
(multiple spaces after ',')
(‘async’ and ‘await’ are reserved keywords starting with Python 3.7)
Superceeded by #881 |
There are left some
# noqa:
s, and currently I have no idea how to properly fix them