summaryrefslogtreecommitdiff
path: root/sphinx/pycode/parser.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2020-11-06 01:36:04 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2020-11-06 01:36:04 +0900
commit6d5e43a0ffc99830c91e37c026d89a6d70fe52c8 (patch)
tree86101efa1e401be56177237b89e07903cc2c8a18 /sphinx/pycode/parser.py
parent8bf84167a30aa05886fcc1ed8895c8c20e939d89 (diff)
downloadsphinx-git-6d5e43a0ffc99830c91e37c026d89a6d70fe52c8.tar.gz
Drop code for supporting py35
Diffstat (limited to 'sphinx/pycode/parser.py')
-rw-r--r--sphinx/pycode/parser.py9
1 files changed, 2 insertions, 7 deletions
diff --git a/sphinx/pycode/parser.py b/sphinx/pycode/parser.py
index a417b5a1b..78715f777 100644
--- a/sphinx/pycode/parser.py
+++ b/sphinx/pycode/parser.py
@@ -27,12 +27,6 @@ indent_re = re.compile('^\\s*$')
emptyline_re = re.compile('^\\s*(#.*)?$')
-if sys.version_info >= (3, 6):
- ASSIGN_NODES = (ast.Assign, ast.AnnAssign)
-else:
- ASSIGN_NODES = (ast.Assign)
-
-
def filter_whitespace(code: str) -> str:
return code.replace('\f', ' ') # replace FF (form feed) with whitespace
@@ -408,7 +402,8 @@ class VariableCommentPicker(ast.NodeVisitor):
def visit_Expr(self, node: ast.Expr) -> None:
"""Handles Expr node and pick up a comment if string."""
- if (isinstance(self.previous, ASSIGN_NODES) and isinstance(node.value, ast.Str)):
+ if (isinstance(self.previous, (ast.Assign, ast.AnnAssign)) and
+ isinstance(node.value, ast.Str)):
try:
targets = get_assign_targets(self.previous)
varnames = get_lvar_names(targets[0], self.get_self())