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
Q000 is not enforced with inline-quotes = "single"
#11209
Comments
I don't think we touch this because it contains single quotes within it, so changing to single quotes would thus require that we escape the inner quotes, and the rule prefers avoiding escapes. |
@charliermarsh The line should actually be this: f"Connecting to {username}@{hostname} via ssh. " logger.info(
f"Connecting to {username}@{hostname} via ssh. "
f"If you encounter any issues, you can try `ssh -v -p {self._ssh_port} {username}@{hostname}` with the password '{self._ssh_password}' and report the issue on GitHub. "
f"If you started OpenDevin with `docker run`, you should try `ssh -v -p {self._ssh_port} {username}@localhost` with the password '{self._ssh_password} on the host machine (where you started the container)."
) |
https://github.com/zheller/flake8-quotes/, on the other hand, would have caught this line. |
Yeah, we enforce it on the entire implicit concatenation. See: #2400. |
Interesting, this "bug fix" seems to be a "bug" to me and the original version seemed more correct 🤣 but I see why you want to choose this. If one chooses to use single quote, does Q000 attempt to change it to double quotes in this case? From a developer's perspective, I don't care whether it's single quote or double quote - as long as the linter could enforce a consistent behavior, I am happy. |
No, the rule wouldn't convert a single-quoted string to a double-quoted string if the user preferred the "single" quotes in their config. But, in your case, there's a single quote in the string content which is why Ruff doesn't flag the string. This is to maintain consistency across all the parts of an implicitly concatenated string. For example, the following is inconsistent because some parts uses single quotes while others uses double quotes. logger.info(
f'Connecting to {username}@{hostname} via ssh. '
f"If you encounter any issues, you can try `ssh -v -p {self._ssh_port} {username}@{hostname}` with the password '{self._ssh_password}' and report the issue on GitHub. "
f"If you started OpenDevin with `docker run`, you should try `ssh -v -p {self._ssh_port} {username}@localhost` with the password '{self._ssh_password} on the host machine (where you started the container)."
) I think in this case you might get away with using logger.info(
f'Connecting to {username}@{hostname} via ssh. '
f'If you encounter any issues, you can try `ssh -v -p {self._ssh_port} {username}@{hostname}` with the password {self._ssh_password!r} and report the issue on GitHub. '
f'If you started OpenDevin with `docker run`, you should try `ssh -v -p {self._ssh_port} {username}@localhost` with the password {self._ssh_password!r} on the host machine (where you started the container).'
) This should put the quotes around the
Does this help? |
The behaviors here are intentional and I think we're unlikely to make a bunch of changes to the rule, since we generally recommend using the formatter to enforce this anyway (which also allows specifying single-quote for inline with double-quote for docstrings). |
Thanks, I think we can live with that protocol. @Borda what do you think? Can we close the issue now? |
Closing for now as "working as intended", hopefully clarified by the above! |
following my comment in #7834 (comment) and OpenDevin/OpenDevin#1425 (comment)
We are using
v0.4.1
with preco-commit and setting single-quotes but it is not enforced...This is our config:
and this is the sample string which is untouched
The text was updated successfully, but these errors were encountered: