Skip to content

feat(charts): add StrokeType enum for line annotation styling#486

Merged
palewire merged 1 commit intochekos:mainfrom
palewire:main
Oct 28, 2025
Merged

feat(charts): add StrokeType enum for line annotation styling#486
palewire merged 1 commit intochekos:mainfrom
palewire:main

Conversation

@palewire
Copy link
Copy Markdown
Collaborator

Add a new StrokeType enum to provide type-safe options for stroke patterns in range annotations. This replaces the previous string literal type with an enum that supports SOLID, DASHED, and DOTTED line styles.

Changes:

  • Create StrokeType enum in charts/enums/annos.py (renamed from connector_line.py)
  • Update RangeAnnotation.stroke_type field to accept StrokeType | str
  • Add field validator to ensure string values match valid StrokeType values
  • Export StrokeType in all relevant init.py files
  • Add documentation for StrokeType enum

This improves type safety and IDE autocomplete support while maintaining backward compatibility with string values.

Add a new StrokeType enum to provide type-safe options for stroke patterns
in range annotations. This replaces the previous string literal type with
an enum that supports SOLID, DASHED, and DOTTED line styles.

Changes:
- Create StrokeType enum in charts/enums/annos.py (renamed from connector_line.py)
- Update RangeAnnotation.stroke_type field to accept StrokeType | str
- Add field validator to ensure string values match valid StrokeType values
- Export StrokeType in all relevant __init__.py files
- Add documentation for StrokeType enum

This improves type safety and IDE autocomplete support while maintaining
backward compatibility with string values.
@palewire palewire requested a review from Copilot October 28, 2025 23:19
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 introduces a new StrokeType enum to provide type-safe options for controlling the dash pattern of stroke lines in range annotations. Previously, the stroke_type field used a Literal type with string values.

  • Added StrokeType enum with three options: SOLID, DASHED, and DOTTED
  • Updated RangeAnnotation.stroke_type field to accept StrokeType | str instead of Literal
  • Added field validation for string values to ensure they match valid enum values
  • Exported the new enum through module hierarchy

Reviewed Changes

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

Show a summary per file
File Description
datawrapper/charts/enums/annos.py Defines the new StrokeType enum with SOLID, DASHED, and DOTTED options
datawrapper/charts/enums/init.py Updates import statement to include StrokeType from .annos module and adds to __all__ export
datawrapper/charts/annos.py Updates RangeAnnotation.stroke_type field type and adds validator for string inputs
datawrapper/charts/init.py Exports StrokeType to make it available at package level
datawrapper/init.py Exports StrokeType at the top-level module
docs/user-guide/api/enums.rst Adds documentation section for the new StrokeType enum
Comments suppressed due to low confidence (1)

datawrapper/charts/enums/annos.py:55

  • The docstring at line 56 states 'Stroke type options for line annotations', but the enum is placed in a file named annos.py which contains enums for both connector lines and annotations. The module docstring at line 1 says 'Enums for connector line configuration in annotations.' Consider updating the module docstring to reflect that it now contains enums for both connector lines and general annotation styling (like stroke types for range annotations).

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

@palewire palewire merged commit 8b96c3b into chekos:main Oct 28, 2025
15 checks passed
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.

2 participants