2020currentdir = os .path .dirname (os .path .abspath (inspect .getfile (inspect .currentframe ())))
2121parentdir = os .path .dirname (currentdir )
2222sys .path .insert (0 , parentdir )
23- # Third-party imports
24- import click
23+ # Third-party imports (must follow sys.path mutation above).
24+ import click # noqa: E402
2525
26- from scenedetect ._cli import scenedetect
26+ from scenedetect ._cli import scenedetect # noqa: E402
2727
2828StrGenerator = ty .Generator [str , None , None ]
2929
@@ -80,7 +80,7 @@ def patch_help(s: str, commands: ty.List[str]) -> str:
8080
8181 for command in [command for command in commands if command not in INFO_COMMANDS ]:
8282
83- def add_link (_match : re .Match ) -> str :
83+ def add_link (_match : re .Match , command : str = command ) -> str :
8484 return ":ref:`%s <command-%s>`" % (command , command )
8585
8686 s = re .sub ("``%s``(?!\\ n)" % command , add_link , s )
@@ -116,7 +116,7 @@ def add_backquotes_with_refs(refs: ty.Set[str]) -> ty.Callable[[str], str]:
116116
117117 def _add_backquotes (s : re .Match ) -> str :
118118 to_add : str = s .string [s .start () : s .end ()]
119- flag = re .search ("-+[\w-]+[^\.\=\s\/]*" , to_add )
119+ flag = re .search (r "-+[\w-]+[^\.\=\s\/]*" , to_add )
120120 if flag is not None and flag .string [flag .start () : flag .end ()] in refs :
121121 # add cross reference
122122 cross_ref = flag .string [flag .start () : flag .end ()]
@@ -129,7 +129,7 @@ def _add_backquotes(s: re.Match) -> str:
129129
130130
131131def extract_default_value (s : str ) -> ty .Tuple [str , ty .Optional [str ]]:
132- default = re .search ("\[default: .*\]" , s )
132+ default = re .search (r "\[default: .*\]" , s )
133133 if default is not None :
134134 span = default .span ()
135135 assert span [1 ] == len (s )
@@ -145,11 +145,11 @@ def transform_add_option_refs(s: str, refs: ty.List[str]) -> str:
145145 # TODO: Match prefix of `global option` and add ref to parent `scenedetect` command option.
146146 # Replace patch to complete this.
147147 # -c/--command
148- s = re .sub ("-\w/--\w[\w-]*" , transform , s )
148+ s = re .sub (r "-\w/--\w[\w-]*" , transform , s )
149149 # --arg=value, --arg=1.2.3, --arg=1,2,3
150- s = re .sub ('-+[\w-]+=[^"\s\)]+(?<![\.\,])' , transform , s )
150+ s = re .sub (r '-+[\w-]+=[^"\s\)]+(?<![\.\,])' , transform , s )
151151 # --args=" command with spaces"
152- s = re .sub ('--[\w-]+[=]+".*?"' , transform , s )
152+ s = re .sub (r '--[\w-]+[=]+".*?"' , transform , s )
153153 return s
154154
155155
@@ -252,7 +252,9 @@ def create_help() -> ty.Tuple[str, ty.List[str]]:
252252 ctx = click .Context (scenedetect , info_name = scenedetect .name )
253253
254254 commands : ty .List [str ] = ctx .command .list_commands (ctx )
255- commands = list (filter (lambda command : not ctx .command .get_command (ctx , command ).hidden , commands ))
255+ commands = list (
256+ filter (lambda command : not ctx .command .get_command (ctx , command ).hidden , commands )
257+ )
256258 # ctx.to_info_dict lacks metavar so we have to use the context directly.
257259 actions = [
258260 generate_title ("``scenedetect`` 🎬 Command" , level = 0 ),
@@ -268,7 +270,10 @@ def create_help() -> ty.Tuple[str, ty.List[str]]:
268270def main ():
269271 help , commands = create_help ()
270272 help = patch_help (help , commands )
271- help = ".. NOTE: This file is auto-generated by docs/generate_cli_docs.py and should not be modified.\n " + help
273+ help = (
274+ ".. NOTE: This file is auto-generated by docs/generate_cli_docs.py and should not be modified.\n "
275+ + help
276+ )
272277 with open ("docs/cli.rst" , "wb" ) as f :
273278 f .write (help .encode ())
274279
0 commit comments