Skip to content

Commit

Permalink
Merge pull request #11 from henribru/bugfix/timestamp-field
Browse files Browse the repository at this point in the history
Fix Timestamp fields not returning DatetimeWithNanoseconds
  • Loading branch information
henribru authored Jan 25, 2024
2 parents 0245caa + 95e5326 commit 5a1513b
Showing 1 changed file with 79 additions and 0 deletions.
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

0 comments on commit 5a1513b

Please sign in to comment.