-
Notifications
You must be signed in to change notification settings - Fork 6
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
false positive S001 on modulo division #23
Comments
@amateja thanks for the report. I also show a warning when two variables are used because I often write code like this:
Another reason was also to consider that a numerical modulo operation is less frequent than string formatting. I'm thinking that we could create a new error code (S002?) for your use case, i.e. when the modulo operation is applied to a variable. This way S001 would be reported whenever a literal string is on the left hand and S002 when is a variable. Improving the checker to use the type hints would be another idea, I like it! though I guess it is not so much widespread that it we be of little use so far (but it can be already handy for you). I'm on vacations until January 9th, before and after that I can not make much promises on these two improvements (new error code and type hints), but I will try my best to make a pull request as soon as possible. Do you have the skills and time to make the necessary changes yourself? If you have code analysis as part of your build or commit hook, you can always temporarily add a |
Hi! I use flake8-pep3101 in my project and I love it (we used it to get rid of % formatting completely from the codebase), but this particular bug sometimes forces us to add more |
Two more years passed, and so far, no hero showed up to get up for the task unfortunately. Although the new release I made still does not solve the problem, at least it brings GitHub actions, and super-easy-to-add tests, which should make the effort of using either type hints (much more widespread nowadays) or a second error code a breeze 🤞🏾 Anyone up for the task? 😄 |
To illustrate, a test to verify that indeed, this is still reported as an error: def test_std_library(self):
source = """
def modulo(foo: int, bar: int) -> int:
return foo % bar
"""
self.check_code(source) Add this to python3.10 -m venv venv
. venv/bin/activate
pip install -r requirements.txt
pytest run_tests.py |
Please consider following example:
Versions 1.1 and 1.2 are affected.
The text was updated successfully, but these errors were encountered: