diff --git a/bikeshed/refs/source.py b/bikeshed/refs/source.py index 89544df7a0..ebc2395f5b 100644 --- a/bikeshed/refs/source.py +++ b/bikeshed/refs/source.py @@ -211,7 +211,7 @@ def forRefsIterator(targetFors: str | list[str]) -> t.Generator[t.RefWrapper, No if exact: refs = list(textRefsIterator([text])) else: - textsToSearch = list(utils.linkTextVariations(text, linkType)) + textsToSearch = list(utils.linkTextVariations(text, linkType, linkFor)) if any(st.endswith("()") for st in textsToSearch): # Let argless methods (either with () at the end, or no parens at all) diff --git a/bikeshed/refs/utils.py b/bikeshed/refs/utils.py index 4b2f7ae782..7257d86af7 100644 --- a/bikeshed/refs/utils.py +++ b/bikeshed/refs/utils.py @@ -58,7 +58,7 @@ def filterOldVersions(refs: list[t.RefWrapper], status: str | None = None) -> li return refs -def linkTextVariations(str: str, linkType: str | None) -> t.Generator[str, None, None]: +def linkTextVariations(str: str, linkType: str | None, linkFor: str | None = None) -> t.Generator[str, None, None]: # Generate intelligent variations of the provided link text, # so explicitly adding an lt attr isn't usually necessary. str = str.strip() @@ -172,7 +172,9 @@ def linkTextVariations(str: str, linkType: str | None) -> t.Generator[str, None, # Let people refer to methods without the parens. # Since attrs and methods live in the same namespace, this is safe. - if "(" not in str: + # But we want to avoid *other* confusions, like an interface and its constructor, + # so qualify it on there being a for value. + if linkFor and "(" not in str: yield str + "()" # Allow linking to an enum-value with or without quotes