Mypy-protobuf

Latest version: v3.6.0

Safety actively analyzes 629564 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 2 of 5

3.0.0

- Drop support for targeting python 2.7
- Generate py3 specific syntax for unicode strings (`""` rather than `u""`)
- Now requires protobuf 3.18.0
- Handle escaping properly in docstrings and attribute strings (296)
- Use three-digit version number 3.0.0 for minor and patch releases
- Codify pyright support in README

2.10

- Switch from setup.py to pyproject.toml and setup.cfg per https://packaging.python.org/tutorials/packaging-projects/
- Remove dependency on grpcio-tools. mypy-protobuf doesn't need it to run. It's only needed to run mypy afterward.
- Avoid relative imports in `_grpc_pb2.pyi` stubs. grpc stubs themselves don't use relative imports, nor `__init__.py` files
- Use `"""` docstring style comments in generated code rather than `` style so it shows up in IDEs.
- Disambiguate messages from reserved python keywords (eg `None`) with prefix `_r_` rather than `__` - since `__` is considered private.
- Bump tests to use pyright 1.1.169, types-protobuf 3.17.4, pytest 6.2.5, grpc-stubs 1.24.7, grpcio-tools 1.40.0
- Since upstream protobuf has dropped support with 3.18.0, 2.10 will be the last mypy-protobuf that supports targeting python 2.7. Updated docs for this.

2.9

- [Rename master branch to main](https://github.com/github/renaming)
- Make `install_requires` requirements for grpcio-tools and types-protobuf use >=

2.8

- Propagate comments from .proto files to .pyi files
- Add protobuf type stubs to the setup requirements
- Fix [239](https://github.com/nipunn1313/mypy-protobuf/issues/239) Remove type: ignore used in enum by pulling `V` into a separate class.
- Use pytest 6.2.4 for internal test suites on python3
- Remove `protoc_gen_mypy.bat` as the entry-points method creates protoc-gen-mypy.exe. Add test confirming.

2.7

- Fix [244](https://github.com/nipunn1313/mypy-protobuf/issues/244) - support extensions defined at module scope with proper types, matching extensions defined within Messages. See [`_ExtensionDict`](https://github.com/python/typeshed/blob/4765978f6ceeb24e10bdf93c0d4b72dfb35836d4/stubs/protobuf/google/protobuf/internal/extension_dict.pyi#L9)

proto
extend google.protobuf.MessageOptions {
string test_message_option = 51234;
}


python
Used to generate
test_message_option: google.protobuf.descriptor.FieldDescriptor = ...

Now generates
test_message_option: google.protobuf.internal.extension_dict._ExtensionFieldDescriptor[google.protobuf.descriptor_pb2.MessageOptions, typing.Text] = ...


Fix repeated extensions as well - to generate RepeatedScalarFieldContainer and RepeatedCompositeFieldContainer

- Now requires [types-protobuf](https://pypi.org/project/types-protobuf/) 3.17.3
- Fix [238](https://github.com/nipunn1313/mypy-protobuf/issues/238) - handling enum variants that name conflict with EnumTypeWrapper methods
- Improve mypy-protobuf testsuite expected-errors file to make insertions/deletions easier to code review
- Fix [227](https://github.com/nipunn1313/mypy-protobuf/issues/227) - improve support for messages/enums with python reserved keyword names
- Order fields within a message in original .proto file order Previously, they were grouped by scalar/nonscalar. Remove
that grouping to make it a bit easier to correlate .proto files to .pyi files.

2.6

- Bump protoc support to 3.17.3
- Use latest python versions in tests (3.6.14 3.7.11 3.8.11 3.9.6)
- Support reserved names for message types. Previously generated invalid mypy.

proto
message M {
message None {}
None none = 1;
}


- Support `protoc-gen-mypy -V` and `protoc-gen-mypy --version` to print version number
- Return `Optional[Literal[...]]` instead of `Literal[...]` from WhichOneof to support
cases in which none of the fields of the WhichOneof are set. See the following example.

python
def hello(name: str) -> None: ...
n = proto.WhichOneof("name")
hello(n) Will now result in a mypy error.
assert n is not None
hello(n) Should work ok


- Bump mypy version to 0.910, utilizing stubs types-protobuf==0.1.14. See https://mypy-lang.blogspot.com/2021/05/the-upcoming-switch-to-modular-typeshed.html
- Bump grpcio version tested to 1.38.1 and grpc-stubs to 1.24.6
- Generate a ` type: ignore` for enum generated stubs to avoid circular dependency described in 214. Bandaid solution.

Page 2 of 5

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.