Skip to content

Fix variance issue by using Mapping for log.add. #75

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

Merged
merged 1 commit into from
Oct 12, 2022
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
8 changes: 8 additions & 0 deletions examples/data-logging/local.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import log
from microbit import *

entry = {
'temperature': temperature(),
'light': display.read_light_level()
}
log.add(entry)
4 changes: 2 additions & 2 deletions lang/en/typeshed/stdlib/log.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Log data to your micro:bit V2."""

from typing import Literal, Optional, Union, overload
from typing import Literal, Mapping, Optional, Union, overload

MILLISECONDS = 1
"""Milliseconds timestamp format."""
Expand Down Expand Up @@ -42,7 +42,7 @@ def set_labels(

@overload
def add(
data_dictionary: Optional[dict[str, Union[str, int, float]]],
data_dictionary: Optional[Mapping[str, Union[str, int, float]]],
) -> None:
"""Add a data row to the log by passing a dictionary of headers and values.
Expand Down
4 changes: 2 additions & 2 deletions lang/es-es/typeshed/stdlib/log.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Registra datos en el micro:bit V2. (registrar)"""
from typing import Literal, Optional, Union, overload
from typing import Literal, Mapping, Optional, Union, overload
MILLISECONDS = 1
"""Formato de marca temporal en milisegundos. (milisegundos)"""
SECONDS = 10
Expand Down Expand Up @@ -32,7 +32,7 @@ unit can be selected via the timestamp argument.
...

@overload
def add(data_dictionary: Optional[dict[str, Union[str, int, float]]]) -> None:
def add(data_dictionary: Optional[Mapping[str, Union[str, int, float]]]) -> None:
"""Añade una fila de datos al registro pasando un diccionario de cabeceras y valores. (añadir)

Example: ``log.add({ 'temp': temperature() })``
Expand Down
4 changes: 2 additions & 2 deletions lang/fr/typeshed/stdlib/log.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Journalisez des données sur votre micro:bit V2."""
from typing import Literal, Optional, Union, overload
from typing import Literal, Mapping, Optional, Union, overload
MILLISECONDS = 1
"""Format d'horodatage en millisecondes."""
SECONDS = 10
Expand Down Expand Up @@ -32,7 +32,7 @@ unit can be selected via the timestamp argument.
...

@overload
def add(data_dictionary: Optional[dict[str, Union[str, int, float]]]) -> None:
def add(data_dictionary: Optional[Mapping[str, Union[str, int, float]]]) -> None:
"""Ajoute une ligne de données au journal en passant un dictionnaire d'en-têtes et de valeurs.

Example: ``log.add({ 'temp': temperature() })``
Expand Down
4 changes: 2 additions & 2 deletions lang/ja/typeshed/stdlib/log.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""micro:bit V2のログにデータを記録します。"""
from typing import Literal, Optional, Union, overload
from typing import Literal, Mapping, Optional, Union, overload
MILLISECONDS = 1
"""ミリ秒単位の日時フォーマット。"""
SECONDS = 10
Expand Down Expand Up @@ -32,7 +32,7 @@ unit can be selected via the timestamp argument.
...

@overload
def add(data_dictionary: Optional[dict[str, Union[str, int, float]]]) -> None:
def add(data_dictionary: Optional[Mapping[str, Union[str, int, float]]]) -> None:
"""ヘッダーと値の辞書を渡すことにより、ログにデータ行を追加します。

Example: ``log.add({ 'temp': temperature() })``
Expand Down
4 changes: 2 additions & 2 deletions lang/ko/typeshed/stdlib/log.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""micro:bit V2에 데이터를 기록합니다."""
from typing import Literal, Optional, Union, overload
from typing import Literal, Mapping, Optional, Union, overload
MILLISECONDS = 1
"""밀리초 타임스탬프 형식입니다."""
SECONDS = 10
Expand Down Expand Up @@ -32,7 +32,7 @@ unit can be selected via the timestamp argument.
...

@overload
def add(data_dictionary: Optional[dict[str, Union[str, int, float]]]) -> None:
def add(data_dictionary: Optional[Mapping[str, Union[str, int, float]]]) -> None:
"""헤더 및 값의 딕셔너리를 패스해 로그에 데이터 행을 추가합니다.

Example: ``log.add({ 'temp': temperature() })``
Expand Down
4 changes: 2 additions & 2 deletions lang/zh-cn/typeshed/stdlib/log.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""将数据记录到您的 micro:bit V2。 (日志)"""
from typing import Literal, Optional, Union, overload
from typing import Literal, Mapping, Optional, Union, overload
MILLISECONDS = 1
"""毫秒时间戳格式。 (毫秒)"""
SECONDS = 10
Expand Down Expand Up @@ -32,7 +32,7 @@ unit can be selected via the timestamp argument.
...

@overload
def add(data_dictionary: Optional[dict[str, Union[str, int, float]]]) -> None:
def add(data_dictionary: Optional[Mapping[str, Union[str, int, float]]]) -> None:
"""通过传递包含标题和值的字典将数据行添加到日志中。

Example: ``log.add({ 'temp': temperature() })``
Expand Down
4 changes: 2 additions & 2 deletions lang/zh-tw/typeshed/stdlib/log.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""將資料記錄到您的 micro:bit V2。"""
from typing import Literal, Optional, Union, overload
from typing import Literal, Mapping, Optional, Union, overload
MILLISECONDS = 1
"""毫秒時間戳記格式。"""
SECONDS = 10
Expand Down Expand Up @@ -32,7 +32,7 @@ unit can be selected via the timestamp argument.
...

@overload
def add(data_dictionary: Optional[dict[str, Union[str, int, float]]]) -> None:
def add(data_dictionary: Optional[Mapping[str, Union[str, int, float]]]) -> None:
"""透過傳遞包含標頭和數值的字典,將資料列新增至紀錄中。

Example: ``log.add({ 'temp': temperature() })``
Expand Down