@@ -71,18 +71,19 @@ def visit_FunctionDef(self, node):
7171 Replace function docstrings
7272 """
7373 docstring = ast .get_docstring (node )
74- if docstring and isinstance (node .body [0 ], ast .Expr ) and isinstance (
75- node .body [0 ].value , ast .Str
76- ):
74+ if docstring and isinstance (node .body [0 ], ast .Expr ) \
75+ and isinstance (node .body [0 ].value , ast .Constant ) \
76+ and isinstance (node .body [0 ].value .value , str ) \
77+ :
7778 for key_word , replacement in self .replacements .items ():
7879 docstring = docstring .replace (key_word , replacement )
79- node .body [0 ].value .s = docstring
80+ node .body [0 ].value .value = docstring
8081 return self .generic_visit (node )
8182
8283 def visit_Constant (self , node ):
8384 """Replace string type annotations"""
8485 try :
85- node .s = self .replacements .get (node .s , node .s )
86+ node .value = self .replacements .get (node .value , node .value )
8687 except TypeError :
8788 # ignore unhashable types (e.g. list)
8889 pass
@@ -264,7 +265,7 @@ def get_output_path(self, node):
264265 for target in n .targets :
265266 if isinstance (target , ast .Name ) and target .id == self .FILE_ANNOTATION :
266267 # return the output path
267- return n .value .s .replace ("." , "/" ) + ".py"
268+ return n .value .value .replace ("." , "/" ) + ".py"
268269
269270 def visit_Module (self , node ):
270271 # look for __CROSS_SYNC_OUTPUT__ Assign statement
0 commit comments