Skip to content

chore: drop unnecessary | None on LLMError and Mail.send#36147

Merged
asukaminato0721 merged 1 commit into
langgenius:mainfrom
BrianWang1990:chore/cleanup-unnecessary-or-none
May 14, 2026
Merged

chore: drop unnecessary | None on LLMError and Mail.send#36147
asukaminato0721 merged 1 commit into
langgenius:mainfrom
BrianWang1990:chore/cleanup-unnecessary-or-none

Conversation

@BrianWang1990
Copy link
Copy Markdown
Contributor

Summary

Refs #35557.

A couple of small spots where the | None annotation was carrying no
real information and the body never distinguished between None and a
plain empty string. Tighten them to str with a "" default so the
types match actual usage.

This is a follow-on cleanup in the same spirit as #36135, but for
different files.

Changes

  • api/core/errors/error.py: LLMError.description and
    LLMError.__init__(description=...)str | None = Nonestr = "".
    No subclass or caller relies on description is None; the field is only
    set/read as a string.
  • api/extensions/ext_mail.py: Mail.send(from_=...)
    str | None = Nonestr = "". The body uses if not from_: then falls
    back to self._default_send_from, so an empty string and None are
    already equivalent. The only non-test caller
    (tasks/mail_human_input_delivery_task.py) does not pass from_.

Notes

  • I deliberately kept the diff tiny. There are more candidates suggested
    in the issue thread, but several of them have call sites that pass
    None explicitly or rely on is None semantics, so they need more
    thought than a mechanical rewrite.
  • No behavior change. No new tests required: existing email-send tests
    still cover the default-from_ path, and LLMError.description has no
    test that checks the None case.

LLMError.description and Mail.send(from_=...) are always
assigned a string in practice and the bodies never
distinguish between None and an empty string. Tighten the
annotations to str and default to "" so the types match
actual usage.

Refs langgenius#35557
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. refactor labels May 14, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 0.00% 43.70% +43.70%
Strict coverage 0.00% 43.22% +43.22%
Typed symbols 0 22,024 +22,024
Untyped symbols 0 28,690 +28,690
Modules 0 2551 +2,551

@asukaminato0721 asukaminato0721 enabled auto-merge May 14, 2026 03:21
@asukaminato0721 asukaminato0721 added this pull request to the merge queue May 14, 2026
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label May 14, 2026
Merged via the queue into langgenius:main with commit b9e3130 May 14, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer refactor size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants