Skip to content

Commit

Permalink
BUG: Make sure string has at least 2 characters
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinThoma committed Jan 23, 2022
1 parent 3a75af5 commit 31ce0a3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions flake8_simplify.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def __init__(self, orig: ast.Call) -> None:


def strip_parenthesis(string: str) -> str:
if string[0] == "(" and string[-1] == ")":
if len(string) >= 2 and string[0] == "(" and string[-1] == ")":
return string[1:-1]
return string

Expand All @@ -139,7 +139,7 @@ def use_double_quotes(string: str) -> str:
quotes = "'''"
if string.startswith(quotes) and string.endswith(quotes):
return f'"""{string[len(quotes):-len(quotes)]}"""'
if string[0] == "'" and string[-1] == "'":
if len(string) >= 2 and string[0] == "'" and string[-1] == "'":
return f'"{string[1:-1]}"'
return string

Expand Down

0 comments on commit 31ce0a3

Please sign in to comment.