-
-
Notifications
You must be signed in to change notification settings - Fork 378
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
Warn about possibly infinite while
#1007
Comments
|
Hi, I've been looking to contribute to this project and would like to try and implement this rule if nobody is on it! |
Sure, I would be happy to answer your questions! Thanks! |
Hi there! After perusing through the source code and the tutorial documentation, I was thinking that this rule would best fit in wemake_python_styleguide\visitors\ast\loops.py. Does this seem like a good place to start? |
Yes, it does! Do you want to take this one? Feel free to ask for help! 👍 |
Sorry about the delayed responses on this issue! I'll work on this implementation tomorrow. Thanks! |
I was able to successfully call "make test" without any errors when I first cloned the repo, but after implemented a few changes, I go the following error complaining that "no shebang is present:" I thought that this may have been caused by the changed I introduced to the source code, but after recloning the repo, the same error messages persist. I could not find much specific help on this issue online and was wondering if you have run into this? I am running on Ubuntu 18.04 by the way. Thanks! |
This warning means that you file has executable rights, but does not have a sebang Check file rights with You can also send me |
Ah yes, chmod did the trick to fix the file rights. Thanks! |
I'm a bit confused by the error "WPS214 Found too many methods: 9" error that is printed out when flake8 runs in wemake_python_styleguide\visitors\ast\loops.py. It seems like you've talked about this in a previous issue #678. So, do I have to reduce the number of methods that I have added to the WrongLoopVisitor class? I added two functions to this class, one for parsing a node to check if it violates the rule and a helper function. However, this error was still thrown when I did not have a helper function (the number of methods was 8). |
I created a new pull request just in case you need access to see the specific code I am referring to. Thanks! |
Move them to |
Great thanks! I moved those functions to logic and everything seems to be working, but there is an issue right now with running pytest. The rule, as defined, raises the violation in any "while True:" loop that does not contain a break, return, or raise, but there are instances of these loops in some of the other test files like the one below (wemake-python-styleguide/tests/test_visitors/test_ast/test_loops/test_loops/test_lambda_in_loop.py). It seems like there are two options:
I'm leaning towards (1) because it seems like the while loops in these test cases would be incorrect because they don't necessarily exit. Does this seem like the best approach? |
Also, what exactly would an integration test to add to tests/fixtures/noqa.py look like? I'm a bit confused on what I should add here. Like I probably shouldn't just add "while True:" because it might hang forever. |
I think I figured it out. I removed those lines from test_lambda_in_loop.py because they are actual violations of the infinite loop rule. All of the requirements have been satisfied except for the adding of an integration test in noqa.py because I could not figure out how to include an infinite loop without pytest failing when running this file. I'll submit another pull request right now, but please let me know if it is possible to add an integration test for this. Thanks! |
@ragohin may I ask how you fixed the I run Ubuntu 16.04 but we get the same error in Ubuntu 18.04. |
@pandaseal this is related to your folder structure. Run |
@sobolevn should I do it manually for every file that fails? I do not really know how to go about all of it... Any tips? |
It really dependends on your problem and your OS. I don't think that I can help without any further information. You can also just ignore this issue for now. It works on CI correctly. |
@sobolevn We fixed it. Thanks for your help. If anyone else has this problem, this was the solution:
|
@pandaseal you can submit this to |
@sobolevn should I create an issue where we can discuss this further? For example where the information should be added in |
Rule request
Check that
while True
block hasraise
orreturn
.UPD: and
break
too.Thesis
It's OK to not have them for CLI entry point, but in other cases, it can be an error. So, let's ask users explicitly
noqa
such cases to be sure that they really know what they're doing.Reasoning
The text was updated successfully, but these errors were encountered: