feat(charts): add StrokeType enum for line annotation styling#486
Merged
palewire merged 1 commit intochekos:mainfrom Oct 28, 2025
Merged
feat(charts): add StrokeType enum for line annotation styling#486palewire merged 1 commit intochekos:mainfrom
palewire merged 1 commit intochekos:mainfrom
Conversation
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.
Contributor
There was a problem hiding this comment.
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
StrokeTypeenum with three options: SOLID, DASHED, and DOTTED - Updated
RangeAnnotation.stroke_typefield to acceptStrokeType | strinstead ofLiteral - 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.pywhich 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
This improves type safety and IDE autocomplete support while maintaining backward compatibility with string values.