Skip to content

Commit

Permalink
Remove redundant call to _decode_data()
Browse files Browse the repository at this point in the history
In Python 3, ast always returns `str` here, and `_decode_data()` is
basically no-op.
  • Loading branch information
lieryan committed Nov 25, 2022
1 parent 339a99c commit 6f5686c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions rope/base/pyobjects.py
@@ -1,4 +1,5 @@
from rope.base.fscommands import _decode_data
from typing import Optional

from rope.base import ast, exceptions, utils


Expand Down Expand Up @@ -224,13 +225,14 @@ def get_module(self):
current_object = current_object.parent
return current_object

def get_doc(self):
def get_doc(self) -> Optional[str]:
if len(self.get_ast().body) > 0:
expr = self.get_ast().body[0]
if isinstance(expr, ast.Expr) and isinstance(expr.value, ast.Str):
docstring = expr.value.s
coding = self.get_module().coding
return _decode_data(docstring, coding)
assert isinstance(docstring, str)
return docstring
return None

def _get_defined_objects(self):
if self.defineds is None:
Expand Down

0 comments on commit 6f5686c

Please sign in to comment.