Skip to content

Commit

Permalink
add alias msg2py
Browse files Browse the repository at this point in the history
  • Loading branch information
Ed-XCF committed Nov 25, 2021
1 parent 4ef500e commit 34d4108
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pb2py ../test_pb2.py > wow.py

### in Python
```python
from protobuf2pydantic import message2pydantic as msg2py
from protobuf2pydantic import msg2py
from pydantic import validator

import transaction_pb2
Expand Down
3 changes: 3 additions & 0 deletions protobuf2pydantic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ def message2pydantic(message: GeneratedProtocolMessageType) -> Type[BaseModel]:
sub_namespace = {k: v for k, v in globals().items() if not k.startswith("__")}
exec(compile_code, sub_namespace)
return sub_namespace[getter_key]()


msg2py = message2pydantic
3 changes: 3 additions & 0 deletions tests/test___init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ def test_message2pydantic():
klass = message2pydantic(TestMessage)
assert isinstance(klass, ModelMetaclass)
assert klass.__name__ == TestMessage.__name__


test_msg2py = test_message2pydantic

0 comments on commit 34d4108

Please sign in to comment.