Skip to content

Commit

Permalink
Skip files that raise RecursionError (#304):
Browse files Browse the repository at this point in the history
Certain deeply-nested expressions cause the Refurb visitor to blow the stack.
This doesn't seem to be an issue when running with Mypy directly, though this
is probably because we are traversing the entire AST. As a workaround we will
silently ignore files that cause this issue. For debugging purposes there
should probably be a flag to show files that have been ignored (perhaps just
stuff it under the `-v` flag for now).

Also bump version for new release.

Closes #302.
  • Loading branch information
dosisod authored Nov 10, 2023
1 parent 229e7ea commit b5f9f11
Show file tree
Hide file tree
Showing 5 changed files with 468 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "refurb"
version = "1.22.1"
version = "1.22.2"
description = "A tool for refurbish and modernize Python codebases"
authors = ["dosisod"]
license = "GPL-3.0-only"
Expand Down
6 changes: 5 additions & 1 deletion refurb/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import re
import time
from collections.abc import Sequence
from contextlib import suppress
from functools import cache, partial
from importlib import metadata
from io import StringIO
Expand Down Expand Up @@ -189,7 +190,10 @@ def run_refurb(settings: Settings) -> Sequence[Error | str]:
start = time.time()

visitor = RefurbVisitor(checks, settings)
tree.accept(visitor)

# See: https://github.com/dosisod/refurb/issues/302
with suppress(RecursionError):
tree.accept(visitor)

elapsed = time.time() - start

Expand Down
Loading

0 comments on commit b5f9f11

Please sign in to comment.