Skip to content

Commit 0d20e43

Browse files
committed
Fix: move data_Accepted to pydantic validation
1 parent 1c51a92 commit 0d20e43

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,6 @@ cython_debug/
155155
# pyosMeta specific
156156
src/pyosmeta/_version.py
157157
*.pickle
158-
159158
.token
160159
token.txt
160+
_data/*

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- Add: Code coverage setup (#97, @lwasser)
1111
- Fix: Add validation step to categories attr in pydantic model (#105, @lwasser)
1212
- Fix: update pypi publish to use hatch (#82, @lwasser)
13+
- Fix: move data accepted cleanup to pydantic field alias / validation step (@lwasser)
1314

1415
## [v0.15](https://github.com/pyOpenSci/pyosMeta/releases/tag/v0.15)
1516

src/pyosmeta/cli/process_reviews.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def main():
2929
repo_name="software-submission",
3030
label_name="6/pyOS-approved 🚀🚀🚀",
3131
)
32-
32+
# date_accepted_(month/day/year)
3333
# Get all issues for approved packages - load as dict
3434
issues = process_review.return_response()
3535
# TODO: this method parse_issue_header is working but the parsing code is

src/pyosmeta/parse_issues.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,11 @@ class ReviewModel(BaseModel):
161161
reviewer_2: dict[str, str | None] = {}
162162
archive: Optional[str] = None
163163
version_accepted: Optional[str] = None
164-
date_accepted: Optional[str] = None
164+
date_accepted: Optional[str] = Field(
165+
validation_alias=AliasChoices(
166+
"date_accepted_(month/day/year)", "Date accepted"
167+
)
168+
)
165169
created_at: str = None
166170
updated_at: str = None
167171
closed_at: Optional[str] = None
@@ -484,6 +488,7 @@ def parse_issue_header(
484488
review = {}
485489
review_final = {}
486490
for issue in issues:
491+
# Return issue comment as a cleaned list + package name
487492
pkg_name, body_data = self.parse_comment(issue)
488493
if not pkg_name:
489494
continue
@@ -530,7 +535,7 @@ def parse_issue_header(
530535
"archive",
531536
"version_accepted",
532537
"joss_doi",
533-
"date_accepted",
538+
"date_accepted_(month/day/year)",
534539
"categories",
535540
"partners",
536541
"domain",
@@ -555,7 +560,9 @@ def get_issue_meta(
555560
end_range: int,
556561
) -> dict[str, str]:
557562
"""
558-
Parse through the top of an issue and grab the metadata for the review.
563+
Parse through a list of strings, each of which represents a line in the
564+
first comment of a review.
565+
grab the metadata for the review.
559566
560567
Parameters
561568
----------
@@ -572,9 +579,6 @@ def get_issue_meta(
572579
"""
573580
issue_meta = {}
574581
for item in body_data[0:end_range]:
575-
# Clean date accepted element
576-
if "Date accepted".lower() in item[0].lower():
577-
item[0] = "Date accepted"
578582
issue_meta.update(self._get_line_meta(item))
579583

580584
return issue_meta
@@ -612,15 +616,16 @@ def get_repo_endpoints(
612616

613617
def parse_comment(self, issue: dict[str, str]) -> tuple[str, list[str]]:
614618
"""
615-
Parses an issue comment for pyOpenSci review. Returns the package name
619+
Parses the first comment in an issue comment for pyOpenSci review.
620+
This is where the review metadata are stored.
621+
Returns the package name
616622
and the body of the comment parsed into a list of elements.
617623
618624
Parameters
619625
----------
620626
issue : dict
621627
A dictionary containing the json response for an issue comment.
622628
623-
624629
Returns
625630
-------
626631
pkg_name : str

0 commit comments

Comments
 (0)