Skip to content

Fix _add_excel_table: gate warnings behind verbose, ensure workbook-wide unique table names#129

Merged
prosenjitdhole merged 3 commits intoprosenj_cli_hq_eval_report_phase_3from
copilot/sub-pr-100-again
Mar 6, 2026
Merged

Fix _add_excel_table: gate warnings behind verbose, ensure workbook-wide unique table names#129
prosenjitdhole merged 3 commits intoprosenj_cli_hq_eval_report_phase_3from
copilot/sub-pr-100-again

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 6, 2026

_add_excel_table was unconditionally printing on exception (ignoring verbose) and table names were generated per-sheet without collision detection, risking duplicate names after sanitization.

Changes

  • Structured warning collection: Added warnings: Optional[List[str]] parameter to _add_excel_table. Exceptions now append to the caller-supplied list instead of printing directly.

  • Verbose-gated output: _apply_formatting collects table warnings in a local list and only emits them when verbose=True.

  • Workbook-wide name uniqueness: _apply_formatting tracks assigned names in a Set[str] and appends _1, _2, … on collision, truncating the base name to stay within Excel's 255-character limit.

# Before – always printed, no deduplication
except Exception as e:
    print(f"    Warning: Could not create table {table_name}: {e}")

# After – collected, output gated on verbose, names guaranteed unique
except Exception as e:
    if warnings is not None:
        warnings.append(f"Could not create table {table_name}: {e}")

# In _apply_formatting
used_table_names: Set[str] = set()
...
while table_name in used_table_names:
    suffix = f"_{counter}"
    table_name = base_name[: 255 - len(suffix)] + suffix
    counter += 1
used_table_names.add(table_name)

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

… names

Co-authored-by: prosenjitdhole <239307697+prosenjitdhole@users.noreply.github.com>
Copilot AI changed the title [WIP] Update Excel report generation based on review feedback Fix _add_excel_table: gate warnings behind verbose, ensure workbook-wide unique table names Mar 6, 2026
@prosenjitdhole prosenjitdhole marked this pull request as ready for review March 6, 2026 13:46
Copilot AI review requested due to automatic review settings March 6, 2026 13:46
@prosenjitdhole prosenjitdhole merged commit 2680937 into prosenj_cli_hq_eval_report_phase_3 Mar 6, 2026
1 check failed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the HW Queue Excel report generator’s table creation behavior by collecting table-creation failures as warnings (instead of printing unconditionally) and ensuring Excel table names are unique across the entire workbook after sanitization.

Changes:

  • Add an optional warnings collector parameter to _add_excel_table and stop unconditional printing on exceptions.
  • In _apply_formatting, collect table warnings and only print them when verbose=True.
  • Ensure workbook-wide unique table names by tracking used names and suffixing on collisions while respecting Excel’s 255-character limit.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants