Skip to content

feat(sheets): add text wrapping, alignment, and font formatting to format_sheet_range - #416

Merged
taylorwilsdon merged 8 commits into
taylorwilsdon:mainfrom
ugoano:feature/enhanced-sheets-formatting
Feb 6, 2026
Merged

feat(sheets): add text wrapping, alignment, and font formatting to format_sheet_range#416
taylorwilsdon merged 8 commits into
taylorwilsdon:mainfrom
ugoano:feature/enhanced-sheets-formatting

Conversation

@ugoano

@ugoano ugoano commented Feb 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Extends format_sheet_range with comprehensive text formatting capabilities:

  • Text wrapping: wrap_strategy parameter (WRAP, CLIP, OVERFLOW_CELL)
  • Horizontal alignment: horizontal_alignment parameter (LEFT, CENTER, RIGHT)
  • Vertical alignment: vertical_alignment parameter (TOP, MIDDLE, BOTTOM)
  • Font styling: bold and italic boolean parameters
  • Font size: font_size integer parameter

All new parameters work alongside existing color and number format options.

Changes

  • gsheets/sheets_tools.py: Extended format_sheet_range with new parameters
  • core/tool_tiers.yaml: Added format_sheet_range to extended tier
  • README_NEW.md: Updated documentation for extended tier and enhanced description
  • tests/gsheets/test_format_sheet_range.py: Added 21 unit tests

Test Plan

  • All 21 unit tests pass
  • Tests cover wrap_strategy (WRAP, CLIP, OVERFLOW_CELL)
  • Tests cover horizontal alignment (LEFT, CENTER, RIGHT)
  • Tests cover vertical alignment (TOP, MIDDLE, BOTTOM)
  • Tests cover bold and italic formatting
  • Tests cover font_size
  • Tests cover invalid input validation
  • Tests cover case-insensitive parameter handling
  • Tests cover combined parameters with existing color/number format options

Notes

Following feedback from PR #390:

  • Included tool_tiers.yaml entry
  • Updated README documentation
  • Used American English spelling

ugoano and others added 3 commits February 2, 2026 14:18
…rmat_sheet_range

Extends format_sheet_range with new parameters:
- wrap_strategy: WRAP, CLIP, OVERFLOW_CELL
- horizontal_alignment: LEFT, CENTER, RIGHT
- vertical_alignment: TOP, MIDDLE, BOTTOM
- bold: boolean for bold text
- italic: boolean for italic text
- font_size: integer for font size in points

All parameters work alongside existing color and number format options.
Includes 21 unit tests covering all new functionality.
Added to extended tier in tool_tiers.yaml.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Fixed formatting issues in:
- gcalendar/calendar_tools.py
- gsheets/sheets_tools.py
- tests/gsheets/test_format_sheet_range.py

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@taylorwilsdon
taylorwilsdon requested review from Copilot and taylorwilsdon and removed request for Copilot February 4, 2026 17:12
@taylorwilsdon taylorwilsdon self-assigned this Feb 4, 2026
@taylorwilsdon taylorwilsdon added the enhancement New feature or request label Feb 4, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 extends the format_sheet_range function with comprehensive text formatting capabilities, moving it from the Complete tier to the Extended tier. The enhancement adds text wrapping strategies, horizontal and vertical alignment options, and font styling (bold, italic, and size).

Changes:

  • Added 6 new optional parameters to format_sheet_range (wrap_strategy, horizontal_alignment, vertical_alignment, bold, italic, font_size)
  • Refactored implementation into a testable internal function _format_sheet_range_impl
  • Added comprehensive test coverage with 21 unit tests covering all new parameters and edge cases

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
gsheets/sheets_tools.py Extracted implementation to _format_sheet_range_impl and added validation/normalization for new text formatting parameters
tests/gsheets/test_format_sheet_range.py Added 21 unit tests covering wrap strategies, alignments, font styling, parameter validation, and case-insensitive handling
core/tool_tiers.yaml Moved format_sheet_range from complete to extended tier
README_NEW.md Updated tool tier documentation and enhanced feature description
README.md Added format_sheet_range entry to extended tier tools table
gcalendar/calendar_tools.py Reformatted lambda expressions for consistent multi-line parenthesization

Comment thread gsheets/sheets_tools.py
# Build confirmation message
applied_parts = []
if bg_color_parsed:
applied_parts.append(f"background {background_color}")

Copilot AI Feb 4, 2026

Copy link

Choose a reason for hiding this comment

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

The confirmation message uses inconsistent terminology. Line 577 says 'background {background_color}' while this line says 'text color {text_color}'. For consistency, consider using either 'background color' or just 'background' and 'text' for both.

Suggested change
applied_parts.append(f"background {background_color}")
applied_parts.append(f"background color {background_color}")

Copilot uses AI. Check for mistakes.
.get(calendarId=calendar_id, eventId=event_id)
.execute()
lambda: (
service.events().get(calendarId=calendar_id, eventId=event_id).execute()

Copilot AI Feb 4, 2026

Copy link

Choose a reason for hiding this comment

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

This formatting change appears unrelated to the PR's stated purpose of adding text formatting to format_sheet_range. These lambda reformatting changes in calendar_tools.py should be in a separate PR focused on code style consistency.

Copilot uses AI. Check for mistakes.
@taylorwilsdon

Copy link
Copy Markdown
Owner

Looks good, thanks!

@taylorwilsdon
taylorwilsdon requested a review from Copilot February 5, 2026 19:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.

)

error_msg = str(exc_info.value).lower()
assert "wrap_strategy" in error_msg or "wrap" in error_msg

Copilot AI Feb 5, 2026

Copy link

Choose a reason for hiding this comment

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

The error message assertion is overly permissive. The condition or 'wrap' in error_msg could match unintended error messages that happen to contain the word 'wrap' in a different context. Consider tightening the assertion to only check for 'wrap_strategy' or verify the exact error message format.

Suggested change
assert "wrap_strategy" in error_msg or "wrap" in error_msg
assert "wrap_strategy" in error_msg

Copilot uses AI. Check for mistakes.
)

error_msg = str(exc_info.value).lower()
assert "horizontal" in error_msg or "left" in error_msg

Copilot AI Feb 5, 2026

Copy link

Choose a reason for hiding this comment

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

The error message assertion is overly permissive. Checking for 'left' could match unintended messages. Consider checking only for 'horizontal' or 'horizontal_alignment' to ensure the correct error is raised.

Suggested change
assert "horizontal" in error_msg or "left" in error_msg
assert "horizontal" in error_msg or "horizontal_alignment" in error_msg

Copilot uses AI. Check for mistakes.
)

error_msg = str(exc_info.value).lower()
assert "vertical" in error_msg or "top" in error_msg

Copilot AI Feb 5, 2026

Copy link

Choose a reason for hiding this comment

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

The error message assertion is overly permissive. Checking for 'top' could match unintended messages. Consider checking only for 'vertical' or 'vertical_alignment' to ensure the correct error is raised.

Suggested change
assert "vertical" in error_msg or "top" in error_msg
assert "vertical" in error_msg or "vertical_alignment" in error_msg

Copilot uses AI. Check for mistakes.
Arno and others added 3 commits February 6, 2026 00:01
- Use consistent terminology in confirmation message ("background color"
  to match "text color")
- Tighten test assertions for invalid parameter validation to check
  parameter name and all allowed values instead of loose substring matches
- Remove unrelated calendar_tools.py changes (lambda reformatting, guest
  permissions, query_freebusy) that belong in separate PRs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@taylorwilsdon
taylorwilsdon merged commit a0a0a96 into taylorwilsdon:main Feb 6, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants