Skip to content

Commit 4f9ab73

Browse files
mjohanse-emrMichael Johansen
andauthored
Create protobuf waveform stubs and add unit tests. (#14)
* Initial pass at getting the stubs created. Currently getting mypy error. Signed-off-by: Michael Johansen <[email protected]> * Try to change mypy setting to resolve error. Signed-off-by: Michael Johansen <[email protected]> * Fix import statements in unit tests and fix mypy config. Signed-off-by: Michael Johansen <[email protected]> * Get styleguide and pyright passing. Signed-off-by: Michael Johansen <[email protected]> * Remove test placeholder. Signed-off-by: Michael Johansen <[email protected]> * Change linting filters to be pb2 specific. Fix a couple of tests. Signed-off-by: Michael Johansen <[email protected]> * Test improvements. Signed-off-by: Michael Johansen <[email protected]> --------- Signed-off-by: Michael Johansen <[email protected]> Co-authored-by: Michael Johansen <[email protected]>
1 parent beda697 commit 4f9ab73

17 files changed

+1014
-10
lines changed

packages/ni.protobuf.types/poetry.lock

Lines changed: 42 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/ni.protobuf.types/pyproject.toml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ packages = [{include = "ni", from = "src"}]
3232

3333
[tool.poetry.dependencies]
3434
python = "^3.9"
35+
protobuf = {version=">=4.21"}
36+
37+
[tool.poetry.group.dev.dependencies]
38+
types-grpcio = ">=1.0"
39+
types-protobuf = ">=4.21"
3540

3641
[tool.poetry.group.lint.dependencies]
3742
bandit = { version = ">=1.7", extras = ["toml"] }
@@ -65,16 +70,23 @@ skips = [
6570
"B101", # assert_used
6671
]
6772

73+
[tool.ni-python-styleguide]
74+
extend_exclude = "*_pb2_grpc.py,*_pb2_grpc.pyi,*_pb2.py,*_pb2.pyi"
75+
6876
[tool.black]
77+
extend-exclude = '_pb2(_grpc)?\.(py|pyi)$'
6978
line-length = 100
7079

7180
[tool.mypy]
72-
files = "src/,tests/"
81+
mypy_path = "src"
82+
files = "."
7383
namespace_packages = true
7484
strict = true
85+
explicit_package_bases = true
7586

7687
[tool.pyright]
7788
include = ["src/", "tests/"]
89+
exclude = ["**/*_pb2_grpc.py", "**/*_pb2_grpc.pyi", "**/*_pb2.py", "**/*_pb2.pyi"]
7890

7991
[tool.pytest.ini_options]
8092
addopts = "--doctest-modules --doctest-plus --strict-markers"

packages/ni.protobuf.types/src/ni/protobuf/__init__.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/ni.protobuf.types/src/ni/protobuf/types/array_pb2.py

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
"""
2+
@generated by mypy-protobuf. Do not edit manually!
3+
isort:skip_file
4+
---------------------------------------------------------------------
5+
---------------------------------------------------------------------
6+
"""
7+
8+
import builtins
9+
import collections.abc
10+
import google.protobuf.descriptor
11+
import google.protobuf.internal.containers
12+
import google.protobuf.message
13+
import typing
14+
15+
DESCRIPTOR: google.protobuf.descriptor.FileDescriptor
16+
17+
@typing.final
18+
class Double2DArray(google.protobuf.message.Message):
19+
"""---------------------------------------------------------------------
20+
Defines a 2D array of values. The 2D array is stored as a repeated field of
21+
the appropriate element type, a 1D array. It is stored in row major order.
22+
23+
Example:
24+
Repeated Double: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
25+
26+
rows: 2
27+
columns: 5
28+
29+
2D Representation:
30+
1 2 3 4 5
31+
6 7 8 9 10
32+
33+
Indices:
34+
(0,0) (0,1) (0,2) (0,3) (0,4)
35+
(1,0) (1,1) (1,2) (1,3) (1,4)
36+
37+
Remarks:
38+
The length of the 'data' field must be equal to rows * columns.
39+
If it is not, implementations should treat this state as invalid
40+
and return INVALID_ARGUMENT status code if appropriate.
41+
---------------------------------------------------------------------
42+
"""
43+
44+
DESCRIPTOR: google.protobuf.descriptor.Descriptor
45+
46+
ROWS_FIELD_NUMBER: builtins.int
47+
COLUMNS_FIELD_NUMBER: builtins.int
48+
DATA_FIELD_NUMBER: builtins.int
49+
rows: builtins.int
50+
columns: builtins.int
51+
@property
52+
def data(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.float]: ...
53+
def __init__(
54+
self,
55+
*,
56+
rows: builtins.int = ...,
57+
columns: builtins.int = ...,
58+
data: collections.abc.Iterable[builtins.float] | None = ...,
59+
) -> None: ...
60+
def ClearField(self, field_name: typing.Literal["columns", b"columns", "data", b"data", "rows", b"rows"]) -> None: ...
61+
62+
global___Double2DArray = Double2DArray
63+
64+
@typing.final
65+
class String2DArray(google.protobuf.message.Message):
66+
DESCRIPTOR: google.protobuf.descriptor.Descriptor
67+
68+
ROWS_FIELD_NUMBER: builtins.int
69+
COLUMNS_FIELD_NUMBER: builtins.int
70+
DATA_FIELD_NUMBER: builtins.int
71+
rows: builtins.int
72+
columns: builtins.int
73+
@property
74+
def data(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.str]: ...
75+
def __init__(
76+
self,
77+
*,
78+
rows: builtins.int = ...,
79+
columns: builtins.int = ...,
80+
data: collections.abc.Iterable[builtins.str] | None = ...,
81+
) -> None: ...
82+
def ClearField(self, field_name: typing.Literal["columns", b"columns", "data", b"data", "rows", b"rows"]) -> None: ...
83+
84+
global___String2DArray = String2DArray

packages/ni.protobuf.types/src/ni/protobuf/types/placeholder.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/ni.protobuf.types/src/ni/protobuf/types/precision_timestamp_pb2.py

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
"""
2+
@generated by mypy-protobuf. Do not edit manually!
3+
isort:skip_file
4+
---------------------------------------------------------------------
5+
---------------------------------------------------------------------
6+
"""
7+
8+
import builtins
9+
import google.protobuf.descriptor
10+
import google.protobuf.message
11+
import typing
12+
13+
DESCRIPTOR: google.protobuf.descriptor.FileDescriptor
14+
15+
@typing.final
16+
class PrecisionTimestamp(google.protobuf.message.Message):
17+
"""A PrecisionTimestamp represents a point in time expressed in NI Binary Time Format (NI-BTF).
18+
https://www.ni.com/docs/en-US/bundle/labwindows-cvi/page/cvi/libref/ni-btf.htm
19+
NI-BTF stores time values in Coordinated Universal Time (UTC) format.
20+
A PrecisionTimestamp is encoded as a count of seconds and fractions of seconds at
21+
2^-64 resolution. The count is relative to an epoch of January 1, 1904.
22+
"""
23+
24+
DESCRIPTOR: google.protobuf.descriptor.Descriptor
25+
26+
SECONDS_FIELD_NUMBER: builtins.int
27+
FRACTIONAL_SECONDS_FIELD_NUMBER: builtins.int
28+
seconds: builtins.int
29+
"""Represents the number of seconds since the epoch
30+
1904-01-01T00:00:00Z.
31+
"""
32+
fractional_seconds: builtins.int
33+
"""Non-negative fractions of a second at 2^-64 resolution."""
34+
def __init__(
35+
self,
36+
*,
37+
seconds: builtins.int = ...,
38+
fractional_seconds: builtins.int = ...,
39+
) -> None: ...
40+
def ClearField(self, field_name: typing.Literal["fractional_seconds", b"fractional_seconds", "seconds", b"seconds"]) -> None: ...
41+
42+
global___PrecisionTimestamp = PrecisionTimestamp

packages/ni.protobuf.types/src/ni/protobuf/types/py.typed

Whitespace-only changes.

packages/ni.protobuf.types/src/ni/protobuf/types/waveform_pb2.py

Lines changed: 61 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)