Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions src/smorg/integrations/linear/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,12 +567,9 @@ def _estimate_of(raw: dict[str, Any]) -> str:
estimate = raw.get("estimate")
if estimate is None:
return ""
if isinstance(estimate, bool) or not isinstance(estimate, (int, float)):
raise Malformed(f"'estimate' was {type(estimate).__name__}, expected a number")
is_whole = float(estimate).is_integer()
if is_whole:
return str(int(estimate))
return str(estimate)
if not isinstance(estimate, dict):
raise Malformed(f"'estimate' was {type(estimate).__name__}, expected an object")
return optional_string(estimate, "name")


def _due_date_of(raw: dict[str, Any]) -> str:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"project": "Improve Redis Scalability",
"projectMilestone": {"id": "m1", "name": "Reduce forever data"},
"dueDate": "2026-09-30",
"estimate": 3,
"estimate": {"value": 3, "name": "M"},
"parentId": "ENG-0",
"attachments": [
{"id": "a1", "title": "chore: widen the column", "subtitle": null, "url": "https://github.com/x/y/pull/12"},
Expand Down
11 changes: 1 addition & 10 deletions tests/integrations/linear/test_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ def test_detail_maps_every_property_and_sub_list():
assert detail.project == "Improve Redis Scalability"
assert detail.milestone == "Reduce forever data"
assert detail.due_date == "2026-09-30"
assert detail.estimate == "3"
assert detail.estimate == "M"

assert (detail.parent.id, detail.parent.title) == ("ENG-0", "the parent epic")
assert detail.parent.status_type == "started"
Expand Down Expand Up @@ -874,15 +874,6 @@ def test_an_unparseable_due_date_is_malformed():
issue_detail_with(detail_handler({"issue": issue}))


def test_a_fractional_estimate_is_kept_and_a_whole_float_reads_as_an_integer():
fractional = json.loads(json.dumps(DETAIL["issue"])) | {"estimate": 3.5}
detail = issue_detail_with(detail_handler({"issue": fractional}))
assert detail.estimate == "3.5"
whole = json.loads(json.dumps(DETAIL["issue"])) | {"estimate": 3.0}
detail = issue_detail_with(detail_handler({"issue": whole}))
assert detail.estimate == "3"


def test_a_pull_request_tag_unwraps_like_an_issue_tag():
issue = json.loads(json.dumps(DETAIL["issue"])) | {
"description": 'closed as <pull-request id="p1" href="https://linear.app/x/review/abc">'
Expand Down