mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
refactor: use not in
and is not
as recommended (#3351)
- https://docs.astral.sh/ruff/rules/not-is-test/ - https://docs.astral.sh/ruff/rules/not-in-test/
This commit is contained in:
parent
1065941767
commit
4fb6fa81ac
5 changed files with 9 additions and 9 deletions
|
@ -313,7 +313,7 @@ class ModelManager(DeprecatedNamesMixin):
|
|||
def rename_field(
|
||||
self, notetype: NotetypeDict, field: FieldDict, new_name: str
|
||||
) -> None:
|
||||
if not field in notetype["flds"]:
|
||||
if field not in notetype["flds"]:
|
||||
raise Exception("invalid field")
|
||||
field["name"] = new_name
|
||||
|
||||
|
|
|
@ -974,7 +974,7 @@ from cards where did in %s"""
|
|||
else:
|
||||
conf["legend"] = {"container": "#%sLegend" % id, "noColumns": 10}
|
||||
conf["series"] = dict(stack=True)
|
||||
if not "yaxis" in conf:
|
||||
if "yaxis" not in conf:
|
||||
conf["yaxis"] = {}
|
||||
conf["yaxis"]["labelWidth"] = 40
|
||||
if "xaxis" not in conf:
|
||||
|
|
|
@ -178,7 +178,7 @@ class AddCards(QMainWindow):
|
|||
break
|
||||
# copy non-empty old fields
|
||||
if (
|
||||
not old_field_value in copied_field_names
|
||||
old_field_value not in copied_field_names
|
||||
and old_note.fields[old_idx]
|
||||
):
|
||||
new_note.fields[new_idx] = old_note.fields[old_idx]
|
||||
|
|
|
@ -149,7 +149,7 @@ class SidebarTreeView(QTreeView):
|
|||
def op_executed(
|
||||
self, changes: OpChanges, handler: object | None, focused: bool
|
||||
) -> None:
|
||||
if changes.browser_sidebar and not handler is self:
|
||||
if changes.browser_sidebar and handler is not self:
|
||||
self._refresh_needed = True
|
||||
if focused:
|
||||
self.refresh_if_needed()
|
||||
|
|
|
@ -38,7 +38,7 @@ for line in re.split(r"[;\{\}]|\*\/", data):
|
|||
if not m:
|
||||
if (
|
||||
line != "}"
|
||||
and not ":root" in line
|
||||
and ":root" not in line
|
||||
and "Copyright" not in line
|
||||
and "License" not in line
|
||||
and "color-scheme" not in line
|
||||
|
@ -55,13 +55,13 @@ for line in re.split(r"[;\{\}]|\*\/", data):
|
|||
# remove trailing ms from time props
|
||||
val = re.sub(r"^(\d+)ms$", r"\1", val)
|
||||
|
||||
if not var in props:
|
||||
if var not in props:
|
||||
props.setdefault(var, {})["comment"] = comment
|
||||
props[var]["light"] = val
|
||||
else:
|
||||
props[var]["dark"] = val
|
||||
else:
|
||||
if not var in colors:
|
||||
if var not in colors:
|
||||
colors.setdefault(var, {})["comment"] = comment
|
||||
colors[var]["light"] = val
|
||||
else:
|
||||
|
@ -80,7 +80,7 @@ with open(colors_py, "w") as buf:
|
|||
buf.write("# This file was automatically generated from _root-vars.scss\n")
|
||||
|
||||
for color, val in colors.items():
|
||||
if not "dark" in val:
|
||||
if "dark" not in val:
|
||||
val["dark"] = val["light"]
|
||||
|
||||
buf.write(re.sub(r"\"\n", '",\n', f"{color} = {json.dumps(val, indent=4)}\n"))
|
||||
|
@ -91,7 +91,7 @@ with open(props_py, "w") as buf:
|
|||
buf.write("# This file was automatically generated from _root-vars.scss\n")
|
||||
|
||||
for prop, val in props.items():
|
||||
if not "dark" in val:
|
||||
if "dark" not in val:
|
||||
val["dark"] = val["light"]
|
||||
|
||||
buf.write(re.sub(r"\"\n", '",\n', f"{prop} = {json.dumps(val, indent=4)}\n"))
|
||||
|
|
Loading…
Reference in a new issue