Python: Bug: TimePlugin timeZoneOffset and timeZoneName always return an empty string
メンテナーはふだん 3 日以内に返信
評価
調査の方向性
バグは python/semantic_kernel/core_plugins/time_plugin.py の time_zone_offset と time_zone_name にあります。両関数はタイムゾーンなしで datetime.datetime.now() を呼び出しているため、%z と %Z が空になります。TimePlugin の既存ユニットテストを読んでください。test_mock_now は now を UTC 付きの値でパッチしています。issue のスニペットで再現してください。両関数が、タイムゾーンのない現在時刻での呼び出しに対してローカルのオフセットとゾーン名を返し、その経路を UTC 付きモックを使わずにテストがカバーすれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
TimePlugin.timeZoneOffset and TimePlugin.timeZoneName always return an empty string.
Where
python/semantic_kernel/core_plugins/time_plugin.py:
@kernel_function(description="Get the current time zone offset", name="timeZoneOffset")
def time_zone_offset(self) -> str:
"""... {{time.timeZoneOffset}} => -08:00"""
now = datetime.datetime.now()
return now.strftime("%z")
@kernel_function(description="Get the current time zone name", name="timeZoneName")
def time_zone_name(self) -> str:
"""... {{time.timeZoneName}} => PST"""
now = datetime.datetime.now()
return now.strftime("%Z")
datetime.datetime.now() without a tz argument returns a naive datetime. For a naive datetime strftime("%z") and strftime("%Z") return "".
The existing unit tests do not catch this because they patch datetime.datetime.now to return a timezone-aware UTC value (test_mock_now), which never happens in real use.
To reproduce
Checked on current main (1b1f64b98), Python 3.13, Windows, local zone US Eastern.
import datetime
from semantic_kernel.core_plugins.time_plugin import TimePlugin
t = TimePlugin()
print(repr(t.time_zone_offset()), repr(t.time_zone_name()))
now = datetime.datetime.now().astimezone()
print(repr(now.strftime("%z")), repr(now.strftime("%Z")))
Actual:
'' ''
'-0400' 'Eastern Daylight Time'
A prompt template such as Time zone: {{time.timeZoneName}} ({{time.timeZoneOffset}}) renders as Time zone: ().
Expected
Both functions return the local zone offset and name. Using datetime.datetime.now().astimezone() gives an aware datetime in the local zone, so %z and %Z are filled.
I have a fix with tests ready and will open a PR for this.
Platform
- Language: Python
- Source: main branch of the repository (1b1f64b98)
- 主要言語
- C#
- スター
- 28.6k
- フォーク
- 4.8k
- 平均マージ
- 2日 12時間
- マージ済み PR(30日)
- 22
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
microsoft/semantic-kernel のほかの issue
-
Python: Bug: AnnotationContent and StreamingAnnotationContent to_element writes CitationType.X, so annotations in a rendered chat history fail to parse対応中かも @CRYPTONIKAV が 2 日前に担当しました。 オープンpython triage
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
microsoft/semantic-kernel#14590 ·
メンテナーはふだん 3 日以内に返信
-
.Net: gpt-image-1 is the default image model in the .NET OpenAI connector, and OpenAI shuts it down on October 23対応中かも @nightcityblade が 13 日前に担当しました。 オープン.NET triage
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
microsoft/semantic-kernel#14526 · コメント 1 件 ·
メンテナーはふだん 3 日以内に返信
-
Python: VolatileMemoryStore.get_batch and get_nearest_matches ignore with_embeddings=False (deepcopy result is discarded)対応中かも @VANDRANKI が 15 日前に担当しました。 オープンpython triage
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
microsoft/semantic-kernel#14522 ·
メンテナーはふだん 3 日以内に返信
-
Python: VolatileMemoryStore.get_nearest_match returns an un-awaited coroutine instead of a (MemoryRecord, score) tuple対応中かも @VANDRANKI が 15 日前に担当しました。 オープンpython triage
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
microsoft/semantic-kernel#14521 ·
メンテナーはふだん 3 日以内に返信
-
.Net: Bug: BinaryContent does not decode the %xx escapes of a non-base64 data URI対応中かも @Laurianti が 15 日前に担当しました。 オープン.NET triage
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
microsoft/semantic-kernel#14518 ·
メンテナーはふだん 3 日以内に返信
microsoft/semantic-kernel の issue をすべて見る
似ている issue
-
7.0
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
unoplatform/uno.extensions#3253 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
Sector-Vestige/Sector-Vestige#476 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
PowerShell/platyPS#868 ·
-
S: Untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
Trauma-Station/Trauma-Station#5058 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 2 日以内に返信