Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Allow deeper recursion in mypy daemon, better error reporting#17707

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
hauntsaninja merged 10 commits intopython:masterfromkcdodd:issue-17706
Apr 17, 2025
Merged
Changes from1 commit
Commits
Show all changes
10 commits
Select commitHold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
NextNext commit
Initial attempt at fixing issue-17706
  • Loading branch information
@kcdodd
kcdodd committedAug 23, 2024
commit00e690ead040dcbd2ee1ef8a64cb62b925dd8a2a
31 changes: 30 additions & 1 deletionmypy/fastparse.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -414,7 +414,36 @@ def visit(self, node: AST | None) -> Any:
method = "visit_" + node.__class__.__name__
visitor = getattr(self, method)
self.visitor_cache[typeobj] = visitor
return visitor(node)

try:

return visitor(node)

except RecursionError as e:
# For very complex expressions it is possible to hit recursion limit
# before reaching a leaf node.
# E.G. x1+x2+x3+...+xn -> BinOp(left=BinOp(left=BinOp(left=...
try:
# But to prove that is the cause of this particular recursion error,
# try to unparse the node
ast3.unparse(node)
except RecursionError:
self.errors.report(
node.lineno,
node.col_offset,
"Expression too complex to parse",
blocker=True,
code=codes.MISC,
)

expr = TempNode(AnyType(TypeOfAny.from_error), no_rhs=True)
self.set_line(expr, node)
return expr

else:
# re-raise original recursion error if it *can* be unparsed,
# maybe this is some other issue that shouldn't be silenced/misdirected
raise e

def set_line(self, node: N, n: AstNode) -> N:
node.line = n.lineno
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp