Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix usage of deprecated APIs #46

Merged
merged 1 commit into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 9 additions & 1 deletion src/flake8_picky_parentheses/_redundant_parentheses.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
from ._util import ParensCords


if sys.version_info < (3, 8):
AstStr = ast.Str
else:
AstStr = ast.Constant


AST_FIX_PREFIXES = {
"else": "if True:\n pass\n",
"elif": "if True:\n pass\n",
Expand Down Expand Up @@ -383,14 +389,16 @@ def _get_exceptions_from_ast(cls, sorted_parens_coords, tree, tokens):
if (
parents
and isinstance(parents[0], (ast.Tuple, ast.List))
and isinstance(node, ast.Str)
and isinstance(node, AstStr)
):
tokens_slice = slice(parens_coord.token_indexes[0] + 1,
parens_coord.token_indexes[1])
string_tokens = [
token for token in tokens[tokens_slice]
if token.type == tokenize.STRING
]
if not string_tokens:
continue
if string_tokens[0].start[0] != string_tokens[-1].start[0]:
rewrite_buffer = ProblemRewrite(parens_coord.open_, None)
last_exception_node = node
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ requires = virtualenv<20.22.0
# install pytest in the virtualenv where commands will be executed
deps = pytest
commands =
pytest tests
pytest tests -W error
Loading