Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Oct 23, 2025. It is now read-only.

Commit d35f861

Browse files
committed
simplify get_errors signature
parsed args are now passed directly
1 parent 7f69710 commit d35f861

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

pycee/errors.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88
from collections import defaultdict
99
from importlib import import_module
1010
from difflib import get_close_matches
11+
from argparse import Namespace
1112

1213
from slugify import slugify
1314

14-
from .utils import DATA_TYPES, BUILTINS, HINT_MESSAGES, API_SEARCH_URL
15+
from .utils import DATA_TYPES, BUILTINS, HINT_MESSAGES, SEARCH_URL
1516
from .utils import (
1617
SINGLE_QUOTE_CHAR,
1718
DOUBLE_QUOTE_CHAR,
@@ -20,7 +21,7 @@
2021
)
2122

2223

23-
def handle_error(error_info: dict, n_questions: int, dry_run: bool = False) -> str:
24+
def handle_error(error_info: dict, cmd_args: Namespace) -> str:
2425
"""Process the incoming error as needed and outputs three possible answer.
2526
output:
2627
query: an URL containing an stackoverflow query about the error.
@@ -66,9 +67,9 @@ def handle_error(error_info: dict, n_questions: int, dry_run: bool = False) -> s
6667
else:
6768
query = url_for_error(error_message) # default query
6869

69-
query = set_pagesize(query, n_questions) if query else None
70+
query = set_pagesize(query, cmd_args.n_questions) if query else None
7071

71-
if dry_run:
72+
if cmd_args.dry_run:
7273
print(query)
7374
exit()
7475

@@ -270,7 +271,7 @@ def get_query_params(error_message: str):
270271
def url_for_error(error_message: str) -> str:
271272
"""Build a valid search url."""
272273

273-
return API_SEARCH_URL + get_query_params(error_message)
274+
return SEARCH_URL + get_query_params(error_message)
274275

275276

276277
def get_quoted_words(error_message: str) -> List[str]:

0 commit comments

Comments
 (0)