File tree Expand file tree Collapse file tree 1 file changed +11
-18
lines changed Expand file tree Collapse file tree 1 file changed +11
-18
lines changed Original file line number Diff line number Diff line change @@ -703,24 +703,17 @@ 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 () as doc )) if (
708+ expect_docstring
709+ ):
710+ if self .is_rewrite_disabled (doc ):
711+ return
712+ expect_docstring = False
713+ case ast .ImportFrom (level = 0 , module = "__future__" ):
714+ pass
715+ case _:
716+ break
724717 pos += 1
725718 # Special case: for a decorated function, set the lineno to that of the
726719 # first decorator, not the `def`. Issue #4984.
You can’t perform that action at this time.
0 commit comments