Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
refactor: drop dead 'if not dictionary' guards across report paths
Closes #2665.

Every site results entry flows through make_site_result (checking.py:788),
which initializes results_site = {} and then unconditionally populates it
(site/username/keywords/parsing_enabled/url_main/cookies up front, checker
at the end, plus status or url_user+future on every branch). It has no
return path that yields an empty dict. check_site_for_username wraps that
result and likewise never returns a falsy entry, and maigret.py does not
construct site-result dicts by hand.

So the four downstream 'if not dictionary: continue' guards (all tagged
'# TODO: fix no site data issue') were dead code — the entries they
guarded against cannot occur. Removed:

  - maigret/maigret.py:101  (extract_ids_from_results)
  - maigret/report.py:151   — 'if not dictionary or dictionary.get("is_similar")'
                              trimmed to just the is_similar check (real logic)
  - maigret/report.py:467  (extended-report builder)
  - maigret/report.py:609  (generate_txt_report)
  - maigret/report.py:627  — 'if not site_result or not site_result.get("status")'
                              trimmed to just the status check (real logic)
  - maigret/report.py:687 (generate_json_report)

plus the four '# TODO: fix no site data issue' comments.

No behavior change for well-formed inputs; downstream .get() calls are
safe because entries are always populated dicts. 292 tests pass.
  • Loading branch information
aznikline committed Jun 23, 2026
commit 82dd21b582ebd5647bac068cc2e17553cb6ba709
4 changes: 0 additions & 4 deletions maigret/maigret.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,6 @@ def extract_ids_from_results(results: Dict[str, SiteResult], db: MaigretDatabase
ids_results = {}
for website_name in results:
dictionary = results[website_name]
# TODO: fix no site data issue
if not dictionary:
continue

new_usernames = dictionary.get('ids_usernames')
if new_usernames:
for u, utype in new_usernames.items():
Expand Down
14 changes: 2 additions & 12 deletions maigret/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def save_graph_report(filename: str, username_results: list, db: MaigretDatabase
username_node_name = graph.add_node(id_type, norm_username)

for website_name, dictionary in results.items():
if not dictionary or dictionary.get("is_similar"):
if dictionary.get("is_similar"):
continue

status = dictionary.get("status")
Expand Down Expand Up @@ -463,10 +463,6 @@ def generate_report_context(username_results: list):

for website_name in results:
dictionary = results[website_name]
# TODO: fix no site data issue
if not dictionary:
continue

if dictionary.get("is_similar"):
continue

Expand Down Expand Up @@ -605,9 +601,6 @@ def generate_txt_report(username: str, results: dict, file):
exists_counter = 0
for website_name in results:
dictionary = results[website_name]
# TODO: fix no site data issue
if not dictionary:
continue
if (
dictionary.get("status")
and dictionary["status"].status == MaigretCheckStatus.CLAIMED
Expand All @@ -623,8 +616,7 @@ def generate_json_report(username: str, results: dict, file, report_type):

for sitename in results:
site_result = results[sitename]
# TODO: fix no site data issue
if not site_result or not site_result.get("status"):
if not site_result.get("status"):
continue

if site_result["status"].status != MaigretCheckStatus.CLAIMED:
Expand Down Expand Up @@ -684,8 +676,6 @@ def design_xmind_sheet(sheet, username, results):

for website_name in results:
dictionary = results[website_name]
if not dictionary:
continue
result_status = dictionary.get("status")
# TODO: fix the reason
if not result_status or result_status.status != MaigretCheckStatus.CLAIMED:
Expand Down
Loading