Skip to content

Commit

Permalink
Merge pull request #46 from robsdedude/fix/deprecated-api
Browse files Browse the repository at this point in the history
Fix usage of deprecated APIs
  • Loading branch information
robsdedude authored Jan 15, 2025
2 parents 3b66829 + b9f6a8d commit d4d81cd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
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

0 comments on commit d4d81cd

Please sign in to comment.