-
Notifications
You must be signed in to change notification settings - Fork 0
#149 - Merge labels from PR and the connected issue #159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ def __init__(self, skip: bool = False): | |
self._present_in_chapters = 0 | ||
self._skip = skip | ||
self._is_release_note_detected: Optional[bool] = None | ||
self._labels: set[str] = set() | ||
self._rls_notes: Optional[str] = None # single annotation here | ||
|
||
# properties | ||
|
@@ -55,6 +56,15 @@ def skip(self) -> bool: | |
"""Check if the record should be skipped during output generation process.""" | ||
return self._skip | ||
|
||
@property | ||
def labels(self) -> list[str]: | ||
""" | ||
Gets the labels of the record. | ||
Returns: | ||
list[str]: A list of labels associated with the record. | ||
""" | ||
return list(self._labels) | ||
|
||
Comment on lines
+59
to
+67
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Make label exposure deterministic to prevent flaky ordering Returning a list from a set yields non-deterministic order; sorting avoids flaky tests and unstable output. Apply: - return list(self._labels)
+ return sorted(self._labels) Optionally, if you’d like a public helper to simplify tests and avoid touching # outside diff – add to Record
def add_labels(self, labels: list[str]) -> None:
self._labels.update(labels) 🤖 Prompt for AI Agents
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not needed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @miroslavpojer, understood! I'll defer to your judgment on this. The current implementation works fine for your use case.
|
||
@property | ||
@abstractmethod | ||
def record_id(self) -> int | str: | ||
|
@@ -82,15 +92,6 @@ def is_open(self) -> bool: | |
bool: True if the record is open, False otherwise. | ||
""" | ||
|
||
@property | ||
@abstractmethod | ||
def labels(self) -> list[str]: | ||
""" | ||
Gets the labels of the record. | ||
Returns: | ||
list[str]: A list of labels associated with the record. | ||
""" | ||
|
||
@property | ||
@abstractmethod | ||
def authors(self) -> list[str]: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Initialize labels via PyGithub API method for compatibility and determinism
Prefer
get_labels()
over the.labels
attribute to avoid SDK differences and lazy-loading surprises. This also aligns with howIssue
labels are typically fetched.Proposed change:
If you want me to normalize casing (e.g.,
.lower()
) for safer chapter matching, I can add that as well.To confirm SDK behavior, please check:
🌐 Web query:
💡 Result:
Use get_labels(). The official PyGithub PullRequest object exposes a get_labels() method (returns a PaginatedList of Label) and label-modifying methods (add_to_labels, remove_from_labels, set_labels, etc.). While some REPL/examples may show a .labels attribute in certain contexts, the documented/official way is pr.get_labels(). [1][2]
Sources:
Use
get_labels()
for deterministic label retrievalReplace the
.labels
attribute with the documentedget_labels()
API, falling back to the attribute for mocks/tests:📝 Committable suggestion
🤖 Prompt for AI Agents