File tree Expand file tree Collapse file tree 1 file changed +9
-18
lines changed
Expand file tree Collapse file tree 1 file changed +9
-18
lines changed Original file line number Diff line number Diff line change @@ -703,24 +703,15 @@ def run(self, mod: ast.Module) -> None:
703703 return
704704 pos = 0
705705 for item in mod .body :
706- if (
707- expect_docstring
708- and isinstance (item , ast .Expr )
709- and isinstance (item .value , ast .Constant )
710- and isinstance (item .value .value , str )
711- ):
712- doc = item .value .value
713- if self .is_rewrite_disabled (doc ):
714- return
715- expect_docstring = False
716- elif (
717- isinstance (item , ast .ImportFrom )
718- and item .level == 0
719- and item .module == "__future__"
720- ):
721- pass
722- else :
723- break
706+ match item :
707+ case ast .Expr (value = ast .Constant (value = str (doc ))) if expect_docstring :
708+ if self .is_rewrite_disabled (doc ):
709+ return
710+ expect_docstring = False
711+ case ast .ImportFrom (level = 0 , module = "__future__" ):
712+ pass
713+ case _:
714+ break
724715 pos += 1
725716 # Special case: for a decorated function, set the lineno to that of the
726717 # first decorator, not the `def`. Issue #4984.
You can’t perform that action at this time.
0 commit comments