pytorch - ✅(Solved) Fix [Python 3.14] Deprecated ast.Str call in flake8-simplify [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
pytorch/pytorch#182158Fetched 2026-05-02 05:26:56
View on GitHub
Comments
0
Participants
1
Timeline
41
Reactions
0
Timeline (top)
subscribed ×26labeled ×6mentioned ×4added_to_project_v2 ×1

Error Message

AttributeError: module 'ast' has no attribute 'Str'

Fix Action

Fix / Workaround

As linters in PyTorch are running in ephemeral uv venvs, it can be easily fixed by bumping flake8-simplify package to 0.30.0.

PR fix notes

PR #182160: [Python 3.14] Bump flake8-simplify version

Description (problem / solution / changelog)

Fixes https://github.com/pytorch/pytorch/issues/182158

Python 3.14 removes legacy AST node classes (ast.Str, ast.Num, ast.NameConstant, etc.) that were deprecated since Python 3.8 and replaced by ast.Constant (see Python 3.14 docs).

This affects astor used by flake8-simplify for AST, so invoking lintrunner on flake8 will throw

AttributeError: module 'ast' has no attribute 'Str'

As linters in PyTorch are running in ephemeral uv venvs, it can be easily fixed by bumping flake8-simplify package to 0.30.0.

Changed files

  • tools/linter/adapters/flake8_linter.py (modified, +1/-1)

Code Example

AttributeError: module 'ast' has no attribute 'Str'

---

intrunner --take FLAKE8 --all-files
RAW_BUFFERClick to expand / collapse

🐛 Describe the bug

Python 3.14 removes legacy AST node classes (ast.Str, ast.Num, ast.NameConstant, etc.) that were deprecated since Python 3.8 and replaced by ast.Constant (see Python 3.14 docs).

This affects astor used by flake8-simplify for AST, so invoking lintrunner on flake8 will throw

AttributeError: module 'ast' has no attribute 'Str'

As linters in PyTorch are running in ephemeral uv venvs, it can be easily fixed by bumping flake8-simplify package to 0.30.0.

Reproducer

intrunner --take FLAKE8 --all-files

Versions

Not tied to any specific PyTorch version, as it's linter issue.

OS: Ubuntu 26.04 LTS (x86_64) Python version: 3.14.4 (main, Apr 8 2026, 04:02:31) [GCC 15.2.0] (64-bit runtime) Python platform: Linux-7.0.0-14-generic-x86_64-with-glibc2.43

cc @seemethere @malfet @pytorch/pytorch-dev-infra

extent analysis

TL;DR

Update the flake8-simplify package to version 0.30.0 to resolve the AttributeError caused by the removal of legacy AST node classes in Python 3.14.

Guidance

  • The issue is caused by the removal of legacy AST node classes in Python 3.14, which are used by flake8-simplify.
  • To fix the issue, update the flake8-simplify package to version 0.30.0, which is compatible with Python 3.14.
  • Run the intrunner --take FLAKE8 --all-files command again after updating the package to verify that the issue is resolved.
  • Ensure that the update is applied to the ephemeral uv venvs where the linters are running.

Example

No code snippet is necessary for this issue, as it can be resolved by updating the flake8-simplify package.

Notes

This solution assumes that the issue is solely caused by the removal of legacy AST node classes in Python 3.14 and that updating the flake8-simplify package will resolve the issue.

Recommendation

Apply workaround: Update the flake8-simplify package to version 0.30.0, as it is a straightforward and targeted solution to the issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

pytorch - ✅(Solved) Fix [Python 3.14] Deprecated ast.Str call in flake8-simplify [1 pull requests, 1 participants]