Compare commits
1 Commits
alex/union
...
dhruv/ecos
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b9d133f718 |
@@ -39,10 +39,13 @@ class Repository(NamedTuple):
|
|||||||
repo: str
|
repo: str
|
||||||
ref: str | None
|
ref: str | None
|
||||||
select: str = ""
|
select: str = ""
|
||||||
|
extend_select: str = ""
|
||||||
ignore: str = ""
|
ignore: str = ""
|
||||||
exclude: str = ""
|
exclude: str = ""
|
||||||
# Generating fixes is slow and verbose
|
# Generating fixes is slow and verbose
|
||||||
show_fixes: bool = False
|
show_fixes: bool = False
|
||||||
|
# Only check Jupyter Notebooks
|
||||||
|
only_ipynb: bool = False
|
||||||
|
|
||||||
@asynccontextmanager
|
@asynccontextmanager
|
||||||
async def clone(self: Self, checkout_dir: Path) -> AsyncIterator[Path]:
|
async def clone(self: Self, checkout_dir: Path) -> AsyncIterator[Path]:
|
||||||
@@ -109,6 +112,10 @@ class Repository(NamedTuple):
|
|||||||
return git_sha_stdout.decode().strip()
|
return git_sha_stdout.decode().strip()
|
||||||
|
|
||||||
|
|
||||||
|
# Rules to check for Jupyter Notebooks. These are the rules that are updated with
|
||||||
|
# additional logic for Jupyter Notebooks.
|
||||||
|
JUPYTER_NOTEBOOK_SELECT = "A,E703,F704,B015,B018,D100"
|
||||||
|
|
||||||
# Repositories to check
|
# Repositories to check
|
||||||
# We check most repositories with the default ruleset instead of all rules to avoid
|
# We check most repositories with the default ruleset instead of all rules to avoid
|
||||||
# noisy reports when new rules are added; see https://github.com/astral-sh/ruff/pull/3590
|
# noisy reports when new rules are added; see https://github.com/astral-sh/ruff/pull/3590
|
||||||
@@ -154,6 +161,21 @@ REPOSITORIES: list[Repository] = [
|
|||||||
Repository("tiangolo", "fastapi", "master"),
|
Repository("tiangolo", "fastapi", "master"),
|
||||||
Repository("yandex", "ch-backup", "main"),
|
Repository("yandex", "ch-backup", "main"),
|
||||||
Repository("zulip", "zulip", "main", select="ALL"),
|
Repository("zulip", "zulip", "main", select="ALL"),
|
||||||
|
# Jupyter Notebooks
|
||||||
|
Repository(
|
||||||
|
"huggingface",
|
||||||
|
"notebooks",
|
||||||
|
"main",
|
||||||
|
select=JUPYTER_NOTEBOOK_SELECT,
|
||||||
|
only_ipynb=True,
|
||||||
|
),
|
||||||
|
Repository(
|
||||||
|
"openai",
|
||||||
|
"openai-cookbook",
|
||||||
|
"main",
|
||||||
|
select=JUPYTER_NOTEBOOK_SELECT,
|
||||||
|
only_ipynb=True,
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
SUMMARY_LINE_RE = re.compile(r"^(Found \d+ error.*)|(.*potentially fixable with.*)$")
|
SUMMARY_LINE_RE = re.compile(r"^(Found \d+ error.*)|(.*potentially fixable with.*)$")
|
||||||
@@ -172,6 +194,7 @@ async def check(
|
|||||||
ignore: str = "",
|
ignore: str = "",
|
||||||
exclude: str = "",
|
exclude: str = "",
|
||||||
show_fixes: bool = False,
|
show_fixes: bool = False,
|
||||||
|
only_ipynb: bool = False,
|
||||||
) -> Sequence[str]:
|
) -> Sequence[str]:
|
||||||
"""Run the given ruff binary against the specified path."""
|
"""Run the given ruff binary against the specified path."""
|
||||||
logger.debug(f"Checking {name} with {ruff}")
|
logger.debug(f"Checking {name} with {ruff}")
|
||||||
@@ -184,12 +207,13 @@ async def check(
|
|||||||
ruff_args.extend(["--exclude", exclude])
|
ruff_args.extend(["--exclude", exclude])
|
||||||
if show_fixes:
|
if show_fixes:
|
||||||
ruff_args.extend(["--show-fixes", "--ecosystem-ci"])
|
ruff_args.extend(["--show-fixes", "--ecosystem-ci"])
|
||||||
|
files = "**/*.ipynb" if only_ipynb else "."
|
||||||
|
|
||||||
start = time.time()
|
start = time.time()
|
||||||
proc = await create_subprocess_exec(
|
proc = await create_subprocess_exec(
|
||||||
ruff.absolute(),
|
ruff.absolute(),
|
||||||
*ruff_args,
|
*ruff_args,
|
||||||
".",
|
files,
|
||||||
stdout=PIPE,
|
stdout=PIPE,
|
||||||
stderr=PIPE,
|
stderr=PIPE,
|
||||||
cwd=path,
|
cwd=path,
|
||||||
@@ -263,6 +287,7 @@ async def compare(
|
|||||||
ignore=repo.ignore,
|
ignore=repo.ignore,
|
||||||
exclude=repo.exclude,
|
exclude=repo.exclude,
|
||||||
show_fixes=repo.show_fixes,
|
show_fixes=repo.show_fixes,
|
||||||
|
only_ipynb=repo.only_ipynb,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
check2 = tg.create_task(
|
check2 = tg.create_task(
|
||||||
@@ -274,6 +299,7 @@ async def compare(
|
|||||||
ignore=repo.ignore,
|
ignore=repo.ignore,
|
||||||
exclude=repo.exclude,
|
exclude=repo.exclude,
|
||||||
show_fixes=repo.show_fixes,
|
show_fixes=repo.show_fixes,
|
||||||
|
only_ipynb=repo.only_ipynb,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
except ExceptionGroup as e:
|
except ExceptionGroup as e:
|
||||||
|
|||||||
Reference in New Issue
Block a user