-
-
Notifications
You must be signed in to change notification settings - Fork 38
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 #123. Skip shebang line if present. #130
Fix #123. Skip shebang line if present. #130
Conversation
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.
Hey @tamere-allo-peter congratulations for your first PR!! :)
Your change looks good, but I'm missing some test that makes sure that we don't break this functionality in the future.
It should go in the tests/unit/test_services.py
, you can copy one of the existent and tweak it to fit your use case (for example this one).
Also as you can see, the CI failed due to lint errors. If you check the development facilities, you will see that you can use make format
to fix most of the linter issues. To see that your tests pass locally before pushing them to the ci, you can use make test
.
Any doubt, do not hesitate to ask
@lyz-code Sorry for the formatting, it should be better now with the new commit. As for the unit test I've added it, although it's very different from the existing ones since we don't test the same function. BTW I'm encountering a lot of problems I can't fix right now (dependencies and the like, entirely unrelated to yamlfix) when running |
tests/unit/test_services.py
Outdated
|
||
fakestdin = StringIO(source) | ||
fakestdin.name = "<stdin>" | ||
result = fix_files((fakestdin,)) |
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.
fix_files
is a wrapper function to run fix_code
for all the files it receives as argument. Therefore, if you test fix_code
you're testing that part of fix_files
.
Given that the setup of the tests of fix_code
is more clear, I'd use it instead.
So my suggestion would be to have in this test:
source = dedent(
"""\
#! /this/line/should/be/ignored
---
program: yamlfix
"""
)
result = fix_code(source)
assert result == source
```
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 respectfully disagree, because my fix for the shebang line problem wasn't implemented in fix_code, but in fix_files. So calling fix_code from the test code to check my patch, which is to fix_files, will always return a failure.
I think it was more straightforward to patch fix_files than fix_code, and I believe it's also the case wrt issue #135
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 see what you mean. There's another reason why I think it's better to implement this functionality at fix_code
level. The program is meant to be used as a library too, and a user may have some string that want's to fix, which doesn't belong from a file. To be able to benefit from your feature, they would need to save that string in a file, and then run fix_files
on it.
Please take a moment to think about it, and if you still think it's not worth it, I'll resolve the conversation and merge the PR.
Sorry the PR is taking so long to be resolved, I'm having some busy days and weren't able to review this sooner :(
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.
OK I'll move the fix to fix_code instead of fix_files and modify the test accordingly. I'll try too do this tomorrow.
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 for the comprehension and the extra work
Could you please paste me the errors you're encountering when you run Did you run |
Mostly fixed the issues
|
I thought it was due to a problem with 2FA but even when adding my PAT to ~/.netrc it doesn't work. Could be a problem with our firewall, although I don't find a problem in the logs I have access to. The following works fine though, but the download is made through ssh, which was open by our network team
|
The I've reverted the changes we made, so we can keep on publishing packages. Can you please update your branch with |
Sorry I think I've done some strange things since I don't really master git... I'll try again in a new PR... |
This adds support for shebang lines, leaving them unmodified if present, fixing issue #123