[CI][RFC] Replace black-jupyter with ruff-format (#37210)
Co-authored-by: Alison Shao <a.shao@wustl.edu>
This commit is contained in:
co-authored by
Alison Shao
parent
2641e427be
commit
28262c20df
+3
-12
@@ -370,12 +370,7 @@ def test_infer_recipe_module_level_def_shadowed_by_method_name(repo: Path) -> No
|
||||
" return foo(x=self.x)\n"
|
||||
),
|
||||
"util.py": (
|
||||
"def keep():\n"
|
||||
" return 1\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"def foo(*, x):\n"
|
||||
" return x + 1\n"
|
||||
"def keep():\n return 1\n\n\ndef foo(*, x):\n return x + 1\n"
|
||||
),
|
||||
},
|
||||
)
|
||||
@@ -437,9 +432,7 @@ def test_infer_recipe_move_leaving_a_forwarding_delegate(repo: Path) -> None:
|
||||
_write(
|
||||
repo,
|
||||
**{
|
||||
"model.py": (
|
||||
"class M:\n" " def work(self, x):\n" " return x + 1\n"
|
||||
),
|
||||
"model.py": ("class M:\n def work(self, x):\n return x + 1\n"),
|
||||
"comp.py": "class C:\n def keep(self):\n return 1\n",
|
||||
},
|
||||
)
|
||||
@@ -448,9 +441,7 @@ def test_infer_recipe_move_leaving_a_forwarding_delegate(repo: Path) -> None:
|
||||
repo,
|
||||
**{
|
||||
"model.py": (
|
||||
"class M:\n"
|
||||
" def work(self, x):\n"
|
||||
" return self.comp.work(x)\n"
|
||||
"class M:\n def work(self, x):\n return self.comp.work(x)\n"
|
||||
),
|
||||
"comp.py": (
|
||||
"class C:\n"
|
||||
|
||||
+2
-6
@@ -2,13 +2,9 @@ import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
_PASSING_PROOF = (
|
||||
"import sys\n"
|
||||
'print("PASS: reproduces the commit byte-for-byte.")\n'
|
||||
"sys.exit(0)\n"
|
||||
)
|
||||
_FAILING_PROOF = (
|
||||
"import sys\n" 'print("RESIDUAL (2 lines):\\n+x\\n-y")\n' "sys.exit(1)\n"
|
||||
'import sys\nprint("PASS: reproduces the commit byte-for-byte.")\nsys.exit(0)\n'
|
||||
)
|
||||
_FAILING_PROOF = 'import sys\nprint("RESIDUAL (2 lines):\\n+x\\n-y")\nsys.exit(1)\n'
|
||||
|
||||
|
||||
def _git(repo: Path, *args: str) -> str:
|
||||
|
||||
+2
-13
@@ -110,13 +110,7 @@ def test_add_typechecking_import_inserts_in_block(tmp_path: Path) -> None:
|
||||
def test_add_typechecking_import_creates_missing_block(tmp_path: Path) -> None:
|
||||
"""With no TYPE_CHECKING block, one is created after the trailing module import."""
|
||||
(tmp_path / "m.py").write_text(
|
||||
"from typing import TYPE_CHECKING\n"
|
||||
"\n"
|
||||
"from a import X\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"def f():\n"
|
||||
" pass\n"
|
||||
"from typing import TYPE_CHECKING\n\nfrom a import X\n\n\ndef f():\n pass\n"
|
||||
)
|
||||
r = Repro("b", "t").add_typechecking_import("m.py", "from b import Y")
|
||||
_apply(r, tmp_path)
|
||||
@@ -215,12 +209,7 @@ def test_add_typechecking_import_raises_without_imports(tmp_path: Path) -> None:
|
||||
def test_add_typechecking_import_drops_a_lone_pass_placeholder(tmp_path: Path) -> None:
|
||||
"""Populating a `pass`-only TYPE_CHECKING block replaces the placeholder."""
|
||||
(tmp_path / "m.py").write_text(
|
||||
"from typing import TYPE_CHECKING\n"
|
||||
"\n"
|
||||
"if TYPE_CHECKING:\n"
|
||||
" pass\n"
|
||||
"\n"
|
||||
"x = 1\n"
|
||||
"from typing import TYPE_CHECKING\n\nif TYPE_CHECKING:\n pass\n\nx = 1\n"
|
||||
)
|
||||
r = Repro("b", "t").add_typechecking_import("m.py", "from b import Y")
|
||||
_apply(r, tmp_path)
|
||||
|
||||
+1
-5
@@ -111,11 +111,7 @@ def test_extract_symbols_to_new_module_drops_relocated_assigns(tmp_path: Path) -
|
||||
" return _FLAG\n"
|
||||
)
|
||||
header = (
|
||||
"from __future__ import annotations\n"
|
||||
"\n"
|
||||
"import os\n"
|
||||
"\n"
|
||||
"_FLAG = os.cpu_count()\n"
|
||||
"from __future__ import annotations\n\nimport os\n\n_FLAG = os.cpu_count()\n"
|
||||
)
|
||||
r = Repro("b", "t").extract_symbols_to_new_module(
|
||||
"src.py",
|
||||
|
||||
+2
-14
@@ -19,13 +19,7 @@ def test_move_assign_relocates_a_module_constant(tmp_path: Path) -> None:
|
||||
_apply(r, tmp_path)
|
||||
assert "LIMIT" not in (tmp_path / "src.py").read_text().split("def stay")[0]
|
||||
assert (tmp_path / "dst.py").read_text() == (
|
||||
"import sys\n"
|
||||
"\n"
|
||||
"LIMIT = 480 # seconds\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"def keep():\n"
|
||||
" return 1\n"
|
||||
"import sys\n\nLIMIT = 480 # seconds\n\n\ndef keep():\n return 1\n"
|
||||
)
|
||||
|
||||
|
||||
@@ -50,13 +44,7 @@ def test_move_assign_relocates_an_annotated_constant(tmp_path: Path) -> None:
|
||||
_apply(r, tmp_path)
|
||||
assert "LIMIT" not in (tmp_path / "src.py").read_text().split("def stay")[0]
|
||||
assert (tmp_path / "dst.py").read_text() == (
|
||||
"import sys\n"
|
||||
"\n"
|
||||
"LIMIT: int = 480\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"def keep():\n"
|
||||
" return 1\n"
|
||||
"import sys\n\nLIMIT: int = 480\n\n\ndef keep():\n return 1\n"
|
||||
)
|
||||
|
||||
|
||||
|
||||
+1
-7
@@ -260,13 +260,7 @@ def test_move_symbol_dedent_leaves_string_literal_interior_lines(
|
||||
)
|
||||
_apply(r, tmp_path)
|
||||
assert (tmp_path / "dst.py").read_text() == (
|
||||
"import os\n"
|
||||
"\n"
|
||||
"def foo(self):\n"
|
||||
" s = '''raw\n"
|
||||
" partial\n"
|
||||
"'''\n"
|
||||
" return s\n"
|
||||
"import os\n\ndef foo(self):\n s = '''raw\n partial\n'''\n return s\n"
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user