-
Notifications
You must be signed in to change notification settings - Fork 13
CFE-4554: Added pyright, pyflakes, and flake8 to GH Actions #246
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
Conversation
e8680ed to
ca25e28
Compare
Ticket: CFE-4554 Signed-off-by: Ole Herman Schumacher Elgesem <ole.elgesem@northern.tech>
Ticket: CFE-4554 Signed-off-by: Ole Herman Schumacher Elgesem <ole.elgesem@northern.tech>
Ticket: CFE-4554 Signed-off-by: Ole Herman Schumacher Elgesem <ole.elgesem@northern.tech>
Ticket: CFE-4554 Signed-off-by: Ole Herman Schumacher Elgesem <ole.elgesem@northern.tech>
Ticket: CFE-4554 Signed-off-by: Ole Herman Schumacher Elgesem <ole.elgesem@northern.tech>
Ticket: CFE-4554 Signed-off-by: Ole Herman Schumacher Elgesem <ole.elgesem@northern.tech>
Ticket: CFE-4554 Signed-off-by: Ole Herman Schumacher Elgesem <ole.elgesem@northern.tech>
Signed-off-by: Ole Herman Schumacher Elgesem <ole.elgesem@northern.tech>
|
|
||
|
|
||
| def read_json(path) -> OrderedDict: | ||
| def read_json(path) -> Union[OrderedDict, None]: |
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.
This seems weird, perhaps it would be better to not return None and instead use exceptions.
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.
In general, I think several suggested asserts should instead be handled exceptions. Some of them might be due to 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.
This seems weird, perhaps it would be better to not return
Noneand instead use exceptions.
In general, there's nothing weird or wrong about having a function which returns None on error. In some cases it might be nicer, in other using an exception can have benefits.
In general, I think several suggested asserts should instead be handled exceptions. Some of them might be due to this.
Yea, some of them should be, however making the assumptions explicit with asserts and enabling stricter enforcement for PRs going forward is still an improvement. Converting the codebase to try to exhaustively handle all error cases will be a bit bigger effort that is outside the scope of this PR.
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 think assert is not the right tool for the job of checking conditions like whether a file exists or not, I think it's rather for checking state that should never be wrong if there are no programming logic mistakes. They can even be disabled. I'm fine with allowing it for the moment in this PR, though. I was just concerned that pyright is suggesting adding such asserts.
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 think assert is not the right tool for the job of checking conditions like whether a file exists or not, I think it's rather for checking state that should never be wrong if there are no programming logic mistakes. They can even be disabled. I'm fine with allowing it for the moment in this PR, though. I was just concerned that pyright is suggesting adding such asserts.
Correct, it is not. asserts are a tool for highlighting programmer's mistakes and making assumptions explicit. That can include whether files exist or not. Currently the code assumes that a file exists in certain places, and it's better that this assumption is explicit rather than implicit.
jakub-nt
left a comment
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.
Can always adjust whatever in future PRs
No description provided.