From 73edc02e1d94b7b4dd2c5c9daf11ebff84369d64 Mon Sep 17 00:00:00 2001 From: igeni Date: Sat, 23 Mar 2024 18:20:48 +0300 Subject: [PATCH] Changed concatenation of strings to f-strings to avoid potential type's mismatch and simplify the code --- scripts/insert_api_refs.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/insert_api_refs.py b/scripts/insert_api_refs.py index f73e4c28bf6..65708b01b4d 100644 --- a/scripts/insert_api_refs.py +++ b/scripts/insert_api_refs.py @@ -23,7 +23,7 @@ def list_functions(source_glob): node = ast.parse(open(sp).read()) # Extract the names of all functions and classes defined in this file defined.extend( - (n.name, module_name + "." + n.name) + (n.name, f"{module_name}.{n.name}") for n in node.body if (isinstance(n, ast.FunctionDef) or isinstance(n, ast.ClassDef)) ) @@ -31,14 +31,14 @@ def list_functions(source_glob): def replace_backticks(source_path, docs_path): - markdown_glob = docs_path + "/*.md" - source_glob = source_path + "/**/*.py" + markdown_glob = f"{docs_path}/*.md" + source_glob = f"{source_path}/**/*.py" methods = list_functions(source_glob) for f in glob.glob(markdown_glob): for n, m in methods: # Match backquoted mentions of the function/class name which are # not already links - pattern = "(?