-
Notifications
You must be signed in to change notification settings - Fork 549
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
Mitigating the Impact of Pylint's Inherent Limitations on Functionality of format.sh
#4212
base: master
Are you sure you want to change the base?
Conversation
In fact, employing the Consequently, we must strike a balance between "comprehensive checks" and "manageable workload." This is why I did not directly modify Looking forward to any insights and guidance provided :) |
The motivation for this PR arose tonight when I ran Success: no issues found in 231 source files
Sky Pylint:
************* Module setup
sky/setup_files/setup.py:161:0: C0301: Line too long (88/80) (line-too-long)
sky/setup_files/setup.py:176:0: C0301: Line too long (100/80) (line-too-long)
sky/setup_files/setup.py:177:0: C0301: Line too long (96/80) (line-too-long)
sky/setup_files/setup.py:180:0: C0301: Line too long (112/80) (line-too-long)
sky/setup_files/setup.py:181:0: C0301: Line too long (113/80) (line-too-long)
sky/setup_files/setup.py:183:0: C0301: Line too long (112/80) (line-too-long)
sky/setup_files/setup.py:184:0: C0301: Line too long (113/80) (line-too-long)
sky/setup_files/setup.py:189:0: C0301: Line too long (86/80) (line-too-long)
sky/setup_files/setup.py:196:0: C0301: Line too long (107/80) (line-too-long)
sky/setup_files/setup.py:225:0: C0301: Line too long (119/80) (line-too-long)
sky/setup_files/setup.py:248:0: C0301: Line too long (109/80) (line-too-long)
sky/setup_files/setup.py:180:0: C4001: Invalid string quote ", should be ' (invalid-string-quote)
sky/setup_files/setup.py:181:0: C4001: Invalid string quote ", should be ' (invalid-string-quote)
sky/setup_files/setup.py:183:0: C4001: Invalid string quote ", should be ' (invalid-string-quote)
sky/setup_files/setup.py:184:0: C4001: Invalid string quote ", should be ' (invalid-string-quote) These errors are not related to the code I modified, prompting me to examine the logic in I discovered that under the initial setting of Upon further investigation, I found that pylint seems not to recurse into directories that do not have an Thus, neither the original code nor the Therefore, we need to provide users with three distinct checking formats:
These are my preliminary thoughts, and I would truly appreciate your guidance. |
Instead of adding another option, how about we just fix those lint issues when |
Yes, I think ideally we can use your @root-hbx What is the performance of |
There are a couple of other issues with
@root-hbx If you're interested in working on these, happy to support these fixes as well. |
Thank you for your suggestions. @Michaelvll It appears that addressing lint issues solely when Additionally, another consideration is that running full file checks in the CI could potentially lead to some confusion for current developers. For example, although their code may previously have received a perfect score of 10/10 in local tests, they could now encounter new issues under the revised CI checks, as highlighted in my previous points. |
Thanks for the fix :) @cg505 Current reason for using I believe your perspective aligns perfectly with @Michaelvll, and I think this is a super fancy idea. The optimal approach might be a manual revision of all files flagged by However, a key drawback is that numerous files, previously unflagged by |
LGTM! If you can resolve these issues, it would make this check much more robust (especially the first point you mentioned). Looking forward to your fix! If there’s anything I can help with, feel free to reach out :D |
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.
One fix on this change, and then let's merge it.
Regarding the other fixes discussed, I'll make them in a separate PR.
@@ -129,6 +129,9 @@ if [[ "$1" == '--files' ]]; then | |||
pylint "${PYLINT_FLAGS[@]}" "${@:2}" | |||
elif [[ "$1" == '--all' ]]; then | |||
# Pylint entire sky directory. | |||
pylint "${PYLINT_FLAGS[@]}" $(git ls-files 'sky/*.py' 'sky/*.pyi') | |||
elif [[ "$1" == '--legacy' ]]; then |
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.
Could you make sure that this flag is handled in the yapf logic as well?
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, I forgot to handle the --legacy
flag for yapf
. If yapf
can ensure full coverage, then the modification should look like this?
## This flag formats individual files. --files *must* be the first command line
## arg to use this option.
if [[ "$1" == '--files' ]]; then
format "${@:2}"
# If `--all` is passed, then any further arguments are ignored and the
# entire python directory is formatted.
elif [[ "$1" == '--all' ]]; then
format_all
elif [[ "$1" == '--legacy' ]]; then
format_all
else
# Format only the files that changed in last commit.
format_changed
fi
echo 'SkyPilot yapf: Done'
The reason for this modification is that pylint
previously used --all
but couldn’t check all files due to its own limitations. If yapf
can check all files when --all
is specified originally, then in the new version, the behavior for --legacy
and --all
should be identical. Do you think that would work?
@cg505 After my testing and verification, |
I am confused. What issue are you referring to for pylint? Why can't we just fix those new errors showing by the new way we call pylint? I don't understand why we have to add a new argument |
In the original check, we used In this pull request, we address this by running BTW, we can also change the commands in CI from As your previous suggestion, we can remove the |
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.
thank you @root-hbx !
I think we will hold off merging this for now until there is a chance to clean up the all the pylint issues a bit more.
Yes, I think this works @cg505. Once all This way, we address all historical issues within this PR and plan to introduce the new features you mentioned in a subsequent PR. |
Here, we introduce an enhancement for the With this update, the
Why is this enhancement necessary? As previously highlighted by @cg505, a huge number of historical pylint issues remain unresolved, which are not pertinent to our primary objectives (last time they were modified was a looooooong time ago). I think manually addressing these nits would be time-consuming and offer little meaningful benefit. This functionality will enable us to bypass these legacy issues temporarily, focusing the Simply put:
Do you think this way of "bypassing the existing excess issues" could work? I would greatly appreciate any suggestions or guidance you could offer. @Michaelvll @cg505 |
This PR aims to enhance the functionality of
format.sh
to provide more comprehensive file checks.The origin of this improvement is as follows:
# .github/workflows/pylint.yml pylint --load-plugins pylint_quotes sky
With
sky
as the only parameter, according to pylint’s check guidelines, it only checked folders withinsky/
that contained an__init__.py
file, along with their internal files.format.sh
as shown below:--all
option should check all subdirectories and internal files withinsky/
. However, due to pylint’s limitations, it can only check subdirectories that contain an__init__.py
file, which does not meet our requirements. Therefore, I implemented the following functionality in my PR:We use
--legacy
to signify the original checking method, and we introduce--all
to check all files (usinggit ls-files 'sky/*.py' 'sky/*.pyi'
as the target files, avoiding pylint’s inherent limitations).TL;DR After this change, we can use
format.sh
like:bash format --all
: check all the files insky/
bash format --legacy
: perform checks as originally designedbash format
: check only files that have changed from masterFurthermore, if this PR is deemed appropriate, we may need to consider updating
.github/workflows/pylint.yml
to align with the enhanced functionality informat.sh
.Currently, it uses
pylint --load-plugins pylint_quotes sky
. If we wanna check all, we need to replace it withpylint --load-plugins pylint_quotes $(git ls-files 'sky/*.py' 'sky/*.pyi')
.Tested (run the relevant ones):
bash format.sh
pytest tests/test_smoke.py
pytest tests/test_smoke.py::test_fill_in_the_name
conda deactivate; bash -i tests/backward_compatibility_tests.sh