refactor: simplify URL pattern matching and cleanup commented code

This commit is contained in:
Paul Gauthier 2024-10-31 14:03:26 -07:00 committed by Paul Gauthier (aider)
parent 85ad2826da
commit 94c5ff2fd2

View file

@ -793,12 +793,11 @@ class Coder:
def check_and_open_urls(self, text: str) -> List[str]:
"""Check text for URLs and offer to open them in a browser."""
url_pattern = re.compile(r"(https?://[^\s/$.?#].[^\s]*?)([.']*$|[.',\s])")
dump(url_pattern)
# ai strip trailing . or ' from the url!
url_pattern = re.compile(r"(https?://[^\s/$.?#].[^\s]*)")
urls = list(set(url_pattern.findall(text))) # Use set to remove duplicates
for url in urls:
dump(url)
#ai strip all trailing .', from url!
if self.io.confirm_ask("Open URL for more info about this error?", subject=url):
webbrowser.open(url)
return urls
@ -1153,10 +1152,10 @@ class Coder:
except retry_exceptions() as err:
# Print the error and its base classes
err_msg = str(err)
# base_classes = []
# for cls in err.__class__.__mro__: # Skip the class itself
#base_classes = []
#for cls in err.__class__.__mro__: # Skip the class itself
# base_classes.append(cls.__name__)
# if base_classes:
#if base_classes:
# err_msg += f"\nBase classes: {' -> '.join(base_classes)}"
self.io.tool_error(err_msg)
retry_delay *= 2