Add labels to Issue and update printer to display them#18
Add labels to Issue and update printer to display them#18
Conversation
There was a problem hiding this comment.
Pull Request Overview
This pull request introduces a Label class and integrates it into the Issue model, while also updating the printer to display these labels alongside the issue title.
- Added a new Label dataclass and updated the Issue dataclass to include labels.
- Updated GraphQL queries in client.py to retrieve label information and modified printer.py to show labels in the issue title display.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| linear/printer.py | Updated title_text to include label display in issue titles. |
| linear/client.py | Introduced Label class, added labels field to Issue, and updated GraphQL queries to fetch label data. |
| # Show labels if present | ||
| if issue.labels: | ||
| label_strs = [ | ||
| f"{Style.BRIGHT}{Fore.WHITE if not label.color else ''}[{label.name}]{Style.RESET_ALL}" |
There was a problem hiding this comment.
The conditional for displaying a label's color is potentially confusing. If label.color is provided, no color code is applied; consider revisiting the logic or adding a comment to clarify the intended behavior.
| f"{Style.BRIGHT}{Fore.WHITE if not label.color else ''}[{label.name}]{Style.RESET_ALL}" | |
| # Use the label's color if provided; otherwise, default to white. | |
| f"{Style.BRIGHT}{label.color if label.color else Fore.WHITE}[{label.name}]{Style.RESET_ALL}" |
| labels=[ | ||
| Label.from_dict(label) | ||
| for label in issue.get("labels", {}).get("nodes", []) | ||
| ] if "labels" in issue else None, |
There was a problem hiding this comment.
[nitpick] For consistency in handling collections, consider defaulting the labels field to an empty list instead of None when the key 'labels' is not present. This can simplify later processing of the labels.
| ] if "labels" in issue else None, | |
| ], |
Introduce a Label class and integrate it into the Issue model. Update the display logic to show labels associated with an issue.