-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add t-string fixtures for rules that do not need to be modified #19146
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
Changes from all commits
db19b86
61bd879
bc50038
9a615df
87aa1d1
7cc2457
b04495d
0034409
896a5b3
f39e725
d505c38
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,4 @@ | ||
| _(f"{'value'}") | ||
|
|
||
| # Don't trigger for t-strings | ||
| _(t"{'value'}") |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,3 +13,7 @@ | |
|
|
||
| info(f"{name}") | ||
| info(f"{__name__}") | ||
|
|
||
| # Don't trigger for t-strings | ||
| info(t"{name}") | ||
| info(t"{__name__}") | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,3 +33,11 @@ class Foo: | |
|
|
||
| def __init__(self, bar): | ||
| self.bar = bar | ||
|
|
||
| # This is a type error, out of scope for the rule | ||
| class Foo: | ||
| __slots__ = t"bar{baz}" | ||
|
Comment on lines
+37
to
+39
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Somewhat perversely someone could put If people are doing that (no way they are) we should probably implement a different lint rule for it though, that just says "why have you done this?" |
||
|
|
||
| def __init__(self, bar): | ||
| self.bar = bar | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -90,3 +90,7 @@ | |
| int(1)and None | ||
| float(1.)and None | ||
| bool(True)and() | ||
|
|
||
|
|
||
| # t-strings are not native literals | ||
| str(t"hey") | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,10 @@ | ||
| --- | ||
| source: crates/ruff_linter/src/rules/flake8_gettext/mod.rs | ||
| snapshot_kind: text | ||
| --- | ||
| INT001.py:1:3: INT001 f-string is resolved before function call; consider `_("string %s") % arg` | ||
| | | ||
| 1 | _(f"{'value'}") | ||
| | ^^^^^^^^^^^^ INT001 | ||
| 2 | | ||
| 3 | # Don't trigger for t-strings | ||
| | |
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.
It's not a 100% clear to me if they should be excluded but I think it's a good starting point and it should be a way less common mistake and they would be a better fit for a
assert-on-always-trueor similar rule.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.
This is what I meant by "cannot be empty". The actual documentation for this rule justifies it as:
which does not apply to t-strings.