Skip to content
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

Fix Timestamp fields not returning DatetimeWithNanoseconds #11

Merged
merged 1 commit into from
Jan 25, 2024
Merged
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
79 changes: 79 additions & 0 deletions proto-stubs/fields.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ from typing import (
overload,
)

from google.protobuf.timestamp_pb2 import Timestamp

from .datetime_helpers import DatetimeWithNanoseconds
from .message import Message
from .primitives import ProtoType

Expand Down Expand Up @@ -89,6 +92,17 @@ class Field(Generic[_T]):
optional: bool = False,
) -> None: ...
@overload
def __init__(
self: Field[DatetimeWithNanoseconds],
proto_type: Literal[ProtoType.MESSAGE],
*,
number: int,
message: type[Timestamp],
oneof: str | None = None,
json_name: str | None = None,
optional: bool = False,
) -> None: ...
@overload
def __init__(
self: Field[_T],
proto_type: Literal[ProtoType.MESSAGE],
Expand All @@ -111,6 +125,16 @@ class Field(Generic[_T]):
optional: bool = False,
) -> None: ...
@overload
def __init__(
self: Field[DatetimeWithNanoseconds],
proto_type: type[Timestamp],
*,
number: int,
oneof: str | None = None,
json_name: str | None = None,
optional: bool = False,
) -> None: ...
@overload
def __init__(
self: Field[_T],
proto_type: type[_T],
Expand Down Expand Up @@ -205,6 +229,17 @@ class RepeatedField(Field[_T]):
optional: bool = False,
) -> None: ...
@overload
def __init__(
self: RepeatedField[DatetimeWithNanoseconds],
proto_type: Literal[ProtoType.MESSAGE],
*,
number: int,
message: type[Timestamp],
oneof: str | None = None,
json_name: str | None = None,
optional: bool = False,
) -> None: ...
@overload
def __init__(
self: RepeatedField[_T],
proto_type: Literal[ProtoType.MESSAGE],
Expand All @@ -227,6 +262,16 @@ class RepeatedField(Field[_T]):
optional: bool = False,
) -> None: ...
@overload
def __init__(
self: RepeatedField[DatetimeWithNanoseconds],
proto_type: type[Timestamp],
*,
number: int,
oneof: str | None = None,
json_name: str | None = None,
optional: bool = False,
) -> None: ...
@overload
def __init__(
self: RepeatedField[_T],
proto_type: type[_T],
Expand Down Expand Up @@ -306,6 +351,15 @@ class MapField(Field[_V], Generic[_K, _V]):
number: int,
) -> None: ...
@overload
def __init__(
self: MapField[int, DatetimeWithNanoseconds],
key_type: _IntegerProtoType,
value_type: Literal[ProtoType.MESSAGE],
*,
number: int,
message: type[Timestamp],
) -> None: ...
@overload
def __init__(
self: MapField[int, _V],
key_type: _IntegerProtoType,
Expand All @@ -324,6 +378,14 @@ class MapField(Field[_V], Generic[_K, _V]):
enum: type[_V],
) -> None: ...
@overload
def __init__(
self: MapField[int, DatetimeWithNanoseconds],
key_type: _IntegerProtoType,
value_type: type[Timestamp],
*,
number: int,
) -> None: ...
@overload
def __init__(
self: MapField[int, _V],
key_type: _IntegerProtoType,
Expand Down Expand Up @@ -390,6 +452,15 @@ class MapField(Field[_V], Generic[_K, _V]):
number: int,
) -> None: ...
@overload
def __init__(
self: MapField[str, DatetimeWithNanoseconds],
key_type: Literal[ProtoType.STRING],
value_type: Literal[ProtoType.MESSAGE],
*,
number: int,
message: type[Timestamp],
) -> None: ...
@overload
def __init__(
self: MapField[str, _V],
key_type: Literal[ProtoType.STRING],
Expand All @@ -408,6 +479,14 @@ class MapField(Field[_V], Generic[_K, _V]):
enum: type[_V],
) -> None: ...
@overload
def __init__(
self: MapField[str, DatetimeWithNanoseconds],
key_type: Literal[ProtoType.STRING],
value_type: type[Timestamp],
*,
number: int,
) -> None: ...
@overload
def __init__(
self: MapField[str, _V],
key_type: Literal[ProtoType.STRING],
Expand Down
Loading