From e75f48c026e0d67d84ea475efce60542aa4537ac Mon Sep 17 00:00:00 2001 From: Yilei Yang Date: Wed, 1 Apr 2026 21:59:04 +0000 Subject: [PATCH 1/2] Speed up flake8-async by telling libcst to skip deepcopy. --- flake8_async/runner.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/flake8_async/runner.py b/flake8_async/runner.py index 4562892..1ee00f1 100644 --- a/flake8_async/runner.py +++ b/flake8_async/runner.py @@ -138,7 +138,14 @@ def __init__(self, options: Options, module: Module): def run(self) -> Iterable[Error]: for v in (*self.utility_visitors, *self.visitors): - self.module = cst.MetadataWrapper(self.module).visit(v) + # The default deepcopy guards against the same CST node object + # appearing at two positions in the tree (metadata is keyed by node + # identity). Parser output and the result of a prior .visit() never + # share nodes, so the copy is wasted work. This stays safe as long + # as no visitor returns a cached CST node from multiple leave_* calls. + self.module = cst.MetadataWrapper( + self.module, unsafe_skip_copy=True + ).visit(v) yield from self.state.problems From 8c6851cebfd1f1116a49b23a056cfb1354124148 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 3 Apr 2026 00:34:53 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- flake8_async/runner.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake8_async/runner.py b/flake8_async/runner.py index 1ee00f1..38ff3f5 100644 --- a/flake8_async/runner.py +++ b/flake8_async/runner.py @@ -143,9 +143,9 @@ def run(self) -> Iterable[Error]: # identity). Parser output and the result of a prior .visit() never # share nodes, so the copy is wasted work. This stays safe as long # as no visitor returns a cached CST node from multiple leave_* calls. - self.module = cst.MetadataWrapper( - self.module, unsafe_skip_copy=True - ).visit(v) + self.module = cst.MetadataWrapper(self.module, unsafe_skip_copy=True).visit( + v + ) yield from self.state.problems