@@ -30,16 +30,15 @@ def get_build_root() -> Path:
3030def is_attribute (module : types .ModuleType , parameter : str ) -> bool :
3131 """Returns true if `parameter` is an attribute of `module`."""
3232 docs = docstring_parser .parse (inspect .getdoc (module ), docstring_parser .DocstringStyle .GOOGLE )
33- for param in docs .params :
33+ for param in docs .params : # noqa: SIM110
3434 # The docstring_parser library can mis-parse arguments like `arg (:obj:`str`)` as `arg (`
3535 # which would create a false-negative below, so we just strip away the extra parenthesis.
3636 if param .args [0 ] == "attribute" and param .arg_name .rstrip (" (" ) == parameter :
3737 return True
38-
3938 return False
4039
4140
42- def linkcode_resolve (repo_link : str , domain : str , info : dict [str , str ]) -> typing . Optional [ str ] :
41+ def linkcode_resolve (repo_link : str , domain : str , info : dict [str , str ]) -> str | None :
4342 """
4443 Function called by linkcode to get the URL for a given resource.
4544
@@ -79,8 +78,7 @@ def linkcode_resolve(repo_link: str, domain: str, info: dict[str, str]) -> typin
7978 # This could be caused by trying to link a class attribute
8079 if is_attribute (symbol [- 1 ], name ):
8180 break
82- else :
83- raise e
81+ raise e
8482
8583 symbol_name = name
8684
@@ -97,8 +95,8 @@ def linkcode_resolve(repo_link: str, domain: str, info: dict[str, str]) -> typin
9795 pos = _global_assign_pos (source , symbol_name )
9896 if pos is None :
9997 raise Exception (f"Could not find symbol `{ symbol_name } ` in { module .__name__ } ." )
100- else :
101- start , end = pos
98+
99+ start , end = pos
102100 _ , offset = inspect .getsourcelines (symbol [- 2 ])
103101 if offset != 0 :
104102 offset -= 1
@@ -126,7 +124,7 @@ class NodeWithBody(typing.Protocol):
126124 body : list [ast .AST ]
127125
128126
129- def _global_assign_pos (ast_ : NodeWithBody , name : str ) -> typing . Union [ tuple [int , int ], None ] :
127+ def _global_assign_pos (ast_ : NodeWithBody , name : str ) -> tuple [int , int ] | None :
130128 """
131129 Find the first instance where the `name` global is defined in `ast_`.
132130
@@ -149,6 +147,7 @@ def _global_assign_pos(ast_: NodeWithBody, name: str) -> typing.Union[tuple[int,
149147 pos_in_if = _global_assign_pos (ast_obj , name )
150148 if pos_in_if is not None :
151149 return pos_in_if
150+ return None
152151
153152
154153def cleanup () -> None :
@@ -200,7 +199,7 @@ def build_api_doc() -> None:
200199 logger .info (f"Skipping api-doc for { output_folder .as_posix ()} as it already exists." )
201200 return
202201
203- result = subprocess .run (cmd , cwd = build_root , stdout = subprocess .PIPE , check = True , env = os .environ )
202+ result = subprocess .run (cmd , cwd = build_root , stdout = subprocess .PIPE , check = True , env = os .environ ) # noqa: S603
204203 logger .debug ("api-doc Output:\n " + result .stdout .decode (encoding = "utf-8" ) + "\n " )
205204
206205 cleanup ()
0 commit comments