diff --git a/poetry.lock b/poetry.lock index a230bac..6f75e20 100644 --- a/poetry.lock +++ b/poetry.lock @@ -440,7 +440,7 @@ dev = ["pre-commit", "tox"] [[package]] name = "poethepoet" -version = "0.5.0" +version = "0.10.0" description = "A task runner that works well with poetry." category = "dev" optional = false @@ -448,13 +448,13 @@ python-versions = ">=3.6,<4.0" [package.dependencies] pastel = ">=0.2.0,<0.3.0" -toml = ">=0.10.1,<0.11.0" +tomlkit = ">=0.6.0,<1.0.0" [[package]] name = "protobuf" version = "3.15.6" description = "Protocol Buffers" -category = "main" +category = "dev" optional = false python-versions = "*" @@ -736,6 +736,14 @@ category = "main" optional = false python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" +[[package]] +name = "tomlkit" +version = "0.7.0" +description = "Style preserving TOML library" +category = "dev" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" + [[package]] name = "tox" version = "3.23.0" @@ -829,12 +837,12 @@ docs = ["sphinx", "jaraco.packaging (>=8.2)", "rst.linker (>=1.9)"] testing = ["pytest (>=4.6)", "pytest-checkdocs (>=1.2.3)", "pytest-flake8", "pytest-cov", "pytest-enabler", "jaraco.itertools", "func-timeout", "pytest-black (>=0.3.7)", "pytest-mypy"] [extras] -compiler = ["black", "jinja2", "protobuf"] +compiler = ["black", "jinja2"] [metadata] lock-version = "1.1" python-versions = "^3.6" -content-hash = "a2673f6ad0bf2b04dffe383a306164bdf9d710400528cb117e564c32d36406e8" +content-hash = "4b9a7cbcb2020dfc8a1c9210ffde228ae153e4540026de1a7e6988cca2b7d9c7" [metadata.files] alabaster = [ @@ -1283,8 +1291,8 @@ pluggy = [ {file = "pluggy-0.13.1.tar.gz", hash = "sha256:15b2acde666561e1298d71b523007ed7364de07029219b604cf808bfa1c765b0"}, ] poethepoet = [ - {file = "poethepoet-0.5.0-py3-none-any.whl", hash = "sha256:dfc7d6666156005ed160b1652270a1fd7acc5329c60d7be170326b33d88b6be2"}, - {file = "poethepoet-0.5.0.tar.gz", hash = "sha256:ef65313de2703f7beead7b05b10668a6c5f216e6c434746d889047562402b619"}, + {file = "poethepoet-0.10.0-py3-none-any.whl", hash = "sha256:6fb3021603d4421c6fcc40072bbcf150a6c52ef70ff4d3be089b8b04e015ef5a"}, + {file = "poethepoet-0.10.0.tar.gz", hash = "sha256:70b97cb194b978dc464c70793e85e6f746cddf82b84a38bfb135946ad71ae19c"}, ] protobuf = [ {file = "protobuf-3.15.6-cp27-cp27m-macosx_10_9_x86_64.whl", hash = "sha256:1771ef20e88759c4d81db213e89b7a1fc53937968e12af6603c658ee4bcbfa38"}, @@ -1434,6 +1442,10 @@ toml = [ {file = "toml-0.10.2-py2.py3-none-any.whl", hash = "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"}, {file = "toml-0.10.2.tar.gz", hash = "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"}, ] +tomlkit = [ + {file = "tomlkit-0.7.0-py2.py3-none-any.whl", hash = "sha256:6babbd33b17d5c9691896b0e68159215a9387ebfa938aa3ac42f4a4beeb2b831"}, + {file = "tomlkit-0.7.0.tar.gz", hash = "sha256:ac57f29693fab3e309ea789252fcce3061e19110085aa31af5446ca749325618"}, +] tox = [ {file = "tox-3.23.0-py2.py3-none-any.whl", hash = "sha256:e007673f3595cede9b17a7c4962389e4305d4a3682a6c5a4159a1453b4f326aa"}, {file = "tox-3.23.0.tar.gz", hash = "sha256:05a4dbd5e4d3d8269b72b55600f0b0303e2eb47ad5c6fe76d3576f4c58d93661"}, diff --git a/pyproject.toml b/pyproject.toml index 9b2677a..97baafd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,7 +17,6 @@ black = { version = ">=19.3b0", optional = true } dataclasses = { version = "^0.7", python = ">=3.6, <3.7" } grpclib = "^0.4.1" jinja2 = { version = "^2.11.2", optional = true } -protobuf = { version = "^3.12.2", optional = true } python-dateutil = "^2.8" [tool.poetry.dev-dependencies] @@ -26,7 +25,7 @@ bpython = "^0.19" grpcio-tools = "^1.30.0" jinja2 = "^2.11.2" mypy = "^0.770" -poethepoet = "^0.5.0" +poethepoet = ">=0.9.0" protobuf = "^3.12.2" pytest = "^5.4.2" pytest-asyncio = "^0.12.0" @@ -43,7 +42,7 @@ asv = "^0.4.2" protoc-gen-python_betterproto = "betterproto.plugin:main" [tool.poetry.extras] -compiler = ["black", "jinja2", "protobuf"] +compiler = ["black", "jinja2"] [tool.poe.tasks] # Dev workflow tasks @@ -55,6 +54,16 @@ docs = { cmd = "sphinx-build docs docs/build", help = "Build the sphinx d bench = { shell = "asv run master^! && asv run HEAD^! && asv compare master HEAD", help = "Benchmark current commit vs. master branch"} clean = { cmd = "rm -rf .asv .coverage .mypy_cache .pytest_cache dist betterproto.egg-info **/__pycache__ tests/output_*", help = "Clean out generated files from the workspace" } +generate_lib.cmd = """ +protoc + --plugin=protoc-gen-custom=src/betterproto/plugin/main.py + --custom_opt=INCLUDE_GOOGLE + --custom_out=src/betterproto/lib + -I /usr/local/include/ + /usr/local/include/google/protobuf/**/*.proto +""" +generate_lib.help = "Regenerate the types in betterproto.lib.google" + # CI tasks full-test = { shell = "poe generate && tox", help = "Run tests with multiple pythons" } check-style = { cmd = "black . --check --diff --exclude tests/output_", help = "Check if code style is correct"} diff --git a/tests/inputs/oneof/test_oneof.py b/tests/inputs/oneof/test_oneof.py index 8a1d3ea..ac9af9e 100644 --- a/tests/inputs/oneof/test_oneof.py +++ b/tests/inputs/oneof/test_oneof.py @@ -6,10 +6,10 @@ from tests.util import get_test_case_json_data def test_which_count(): message = Test() message.from_json(get_test_case_json_data("oneof")[0]) - assert betterproto.which_one_of(message, "foo") == ("count", 100) + assert betterproto.which_one_of(message, "foo") == ("pitied", 100) def test_which_name(): message = Test() message.from_json(get_test_case_json_data("oneof", "oneof_name.json")[0]) - assert betterproto.which_one_of(message, "foo") == ("name", "foobar") + assert betterproto.which_one_of(message, "foo") == ("pitier", "Mr. T")