-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bump gpb deps #146
Bump gpb deps #146
Conversation
The newer versions of OTP couldn't safely build these anymore because some new keywords used (`else`) blocked compilation. Bumping deps brings back compatibility for newer runtime environments.
Looks good to me. I tested this locally and running:
showed a diff: diff --git a/src/hex_pb_names.erl b/src/hex_pb_names.erl
index a9891e0..a79288b 100644
--- a/src/hex_pb_names.erl
+++ b/src/hex_pb_names.erl
@@ -73,15 +73,9 @@
-type '$msg'() :: 'Names'() | 'Package'() | 'Timestamp'().
-export_type(['$msg_name'/0, '$msg'/0]).
--if(?OTP_RELEASE >= 24).
--dialyzer({no_underspecs, encode_msg/2}).
--endif.
-spec encode_msg('$msg'(), '$msg_name'()) -> binary().
encode_msg(Msg, MsgName) when is_atom(MsgName) -> encode_msg(Msg, MsgName, []).
--if(?OTP_RELEASE >= 24).
--dialyzer({no_underspecs, encode_msg/3}).
--endif.
-spec encode_msg('$msg'(), '$msg_name'(), list()) -> binary().
encode_msg(Msg, MsgName, Opts) ->
verify_msg(Msg, MsgName, Opts),
@@ -550,7 +544,6 @@ verify_msg(Msg, MsgName, Opts) ->
-compile({nowarn_unused_function,v_msg_Names/3}).
--dialyzer({nowarn_function,v_msg_Names/3}).
v_msg_Names(#{repository := F2} = M, Path, TrUserData) ->
case M of
#{packages := F1} ->
@@ -572,11 +565,9 @@ v_msg_Names(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_field
v_msg_Names(X, Path, _TrUserData) -> mk_type_error({expected_msg, 'Names'}, X, Path).
-compile({nowarn_unused_function,v_submsg_Package/3}).
--dialyzer({nowarn_function,v_submsg_Package/3}).
v_submsg_Package(Msg, Path, TrUserData) -> v_msg_Package(Msg, Path, TrUserData).
-compile({nowarn_unused_function,v_msg_Package/3}).
--dialyzer({nowarn_function,v_msg_Package/3}).
v_msg_Package(#{name := F1} = M, Path, TrUserData) ->
v_type_string(F1, [name | Path], TrUserData),
case M of
@@ -593,11 +584,9 @@ v_msg_Package(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fie
v_msg_Package(X, Path, _TrUserData) -> mk_type_error({expected_msg, 'Package'}, X, Path).
-compile({nowarn_unused_function,v_submsg_Timestamp/3}).
--dialyzer({nowarn_function,v_submsg_Timestamp/3}).
v_submsg_Timestamp(Msg, Path, TrUserData) -> v_msg_Timestamp(Msg, Path, TrUserData).
-compile({nowarn_unused_function,v_msg_Timestamp/3}).
--dialyzer({nowarn_function,v_msg_Timestamp/3}).
v_msg_Timestamp(#{seconds := F1, nanos := F2} = M, Path, TrUserData) ->
v_type_int64(F1, [seconds | Path], TrUserData),
v_type_int32(F2, [nanos | Path], TrUserData),
@@ -611,19 +600,16 @@ v_msg_Timestamp(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_f
v_msg_Timestamp(X, Path, _TrUserData) -> mk_type_error({expected_msg, 'Timestamp'}, X, Path).
-compile({nowarn_unused_function,v_type_int32/3}).
--dialyzer({nowarn_function,v_type_int32/3}).
v_type_int32(N, _Path, _TrUserData) when is_integer(N), -2147483648 =< N, N =< 2147483647 -> ok;
v_type_int32(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, int32, signed, 32}, N, Path);
v_type_int32(X, Path, _TrUserData) -> mk_type_error({bad_integer, int32, signed, 32}, X, Path).
-compile({nowarn_unused_function,v_type_int64/3}).
--dialyzer({nowarn_function,v_type_int64/3}).
v_type_int64(N, _Path, _TrUserData) when is_integer(N), -9223372036854775808 =< N, N =< 9223372036854775807 -> ok;
v_type_int64(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, int64, signed, 64}, N, Path);
v_type_int64(X, Path, _TrUserData) -> mk_type_error({bad_integer, int64, signed, 64}, X, Path).
-compile({nowarn_unused_function,v_type_string/3}).
--dialyzer({nowarn_function,v_type_string/3}).
v_type_string(S, Path, _TrUserData) when is_list(S); is_binary(S) ->
try unicode:characters_to_binary(S) of
B when is_binary(B) -> ok;
@@ -641,9 +627,8 @@ mk_type_error(Error, ValueSeen, Path) ->
-compile({nowarn_unused_function,prettify_path/1}).
--dialyzer({nowarn_function,prettify_path/1}).
prettify_path([]) -> top_level;
-prettify_path(PathR) -> lists:append(lists:join(".", lists:map(fun atom_to_list/1, lists:reverse(PathR)))).
+prettify_path(PathR) -> string:join(lists:map(fun atom_to_list/1, lists:reverse(PathR)), ".").
-compile({nowarn_unused_function,id/2}).
diff --git a/src/hex_pb_package.erl b/src/hex_pb_package.erl
index 4a8516f..79e33da 100644
--- a/src/hex_pb_package.erl
+++ b/src/hex_pb_package.erl
@@ -86,15 +86,9 @@
-type '$msg'() :: 'Package'() | 'Release'() | 'RetirementStatus'() | 'Dependency'().
-export_type(['$msg_name'/0, '$msg'/0]).
--if(?OTP_RELEASE >= 24).
--dialyzer({no_underspecs, encode_msg/2}).
--endif.
-spec encode_msg('$msg'(), '$msg_name'()) -> binary().
encode_msg(Msg, MsgName) when is_atom(MsgName) -> encode_msg(Msg, MsgName, []).
--if(?OTP_RELEASE >= 24).
--dialyzer({no_underspecs, encode_msg/3}).
--endif.
-spec encode_msg('$msg'(), '$msg_name'(), list()) -> binary().
encode_msg(Msg, MsgName, Opts) ->
verify_msg(Msg, MsgName, Opts),
@@ -807,7 +801,6 @@ verify_msg(Msg, MsgName, Opts) ->
-compile({nowarn_unused_function,v_msg_Package/3}).
--dialyzer({nowarn_function,v_msg_Package/3}).
v_msg_Package(#{name := F2, repository := F3} = M, Path, TrUserData) ->
case M of
#{releases := F1} ->
@@ -831,11 +824,9 @@ v_msg_Package(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fie
v_msg_Package(X, Path, _TrUserData) -> mk_type_error({expected_msg, 'Package'}, X, Path).
-compile({nowarn_unused_function,v_submsg_Release/3}).
--dialyzer({nowarn_function,v_submsg_Release/3}).
v_submsg_Release(Msg, Path, TrUserData) -> v_msg_Release(Msg, Path, TrUserData).
-compile({nowarn_unused_function,v_msg_Release/3}).
--dialyzer({nowarn_function,v_msg_Release/3}).
v_msg_Release(#{version := F1, inner_checksum := F2} = M, Path, TrUserData) ->
v_type_string(F1, [version | Path], TrUserData),
v_type_bytes(F2, [inner_checksum | Path], TrUserData),
@@ -869,11 +860,9 @@ v_msg_Release(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fie
v_msg_Release(X, Path, _TrUserData) -> mk_type_error({expected_msg, 'Release'}, X, Path).
-compile({nowarn_unused_function,v_submsg_RetirementStatus/3}).
--dialyzer({nowarn_function,v_submsg_RetirementStatus/3}).
v_submsg_RetirementStatus(Msg, Path, TrUserData) -> v_msg_RetirementStatus(Msg, Path, TrUserData).
-compile({nowarn_unused_function,v_msg_RetirementStatus/3}).
--dialyzer({nowarn_function,v_msg_RetirementStatus/3}).
v_msg_RetirementStatus(#{reason := F1} = M, Path, TrUserData) ->
v_enum_RetirementReason(F1, [reason | Path], TrUserData),
case M of
@@ -890,11 +879,9 @@ v_msg_RetirementStatus(M, Path, _TrUserData) when is_map(M) -> mk_type_error({mi
v_msg_RetirementStatus(X, Path, _TrUserData) -> mk_type_error({expected_msg, 'RetirementStatus'}, X, Path).
-compile({nowarn_unused_function,v_submsg_Dependency/3}).
--dialyzer({nowarn_function,v_submsg_Dependency/3}).
v_submsg_Dependency(Msg, Path, TrUserData) -> v_msg_Dependency(Msg, Path, TrUserData).
-compile({nowarn_unused_function,v_msg_Dependency/3}).
--dialyzer({nowarn_function,v_msg_Dependency/3}).
v_msg_Dependency(#{package := F1, requirement := F2} = M, Path, TrUserData) ->
v_type_string(F1, [package | Path], TrUserData),
v_type_string(F2, [requirement | Path], TrUserData),
@@ -923,7 +910,6 @@ v_msg_Dependency(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_
v_msg_Dependency(X, Path, _TrUserData) -> mk_type_error({expected_msg, 'Dependency'}, X, Path).
-compile({nowarn_unused_function,v_enum_RetirementReason/3}).
--dialyzer({nowarn_function,v_enum_RetirementReason/3}).
v_enum_RetirementReason('RETIRED_OTHER', _Path, _TrUserData) -> ok;
v_enum_RetirementReason('RETIRED_INVALID', _Path, _TrUserData) -> ok;
v_enum_RetirementReason('RETIRED_SECURITY', _Path, _TrUserData) -> ok;
@@ -933,7 +919,6 @@ v_enum_RetirementReason(V, _Path, _TrUserData) when -2147483648 =< V, V =< 21474
v_enum_RetirementReason(X, Path, _TrUserData) -> mk_type_error({invalid_enum, 'RetirementReason'}, X, Path).
-compile({nowarn_unused_function,v_type_bool/3}).
--dialyzer({nowarn_function,v_type_bool/3}).
v_type_bool(false, _Path, _TrUserData) -> ok;
v_type_bool(true, _Path, _TrUserData) -> ok;
v_type_bool(0, _Path, _TrUserData) -> ok;
@@ -941,7 +926,6 @@ v_type_bool(1, _Path, _TrUserData) -> ok;
v_type_bool(X, Path, _TrUserData) -> mk_type_error(bad_boolean_value, X, Path).
-compile({nowarn_unused_function,v_type_string/3}).
--dialyzer({nowarn_function,v_type_string/3}).
v_type_string(S, Path, _TrUserData) when is_list(S); is_binary(S) ->
try unicode:characters_to_binary(S) of
B when is_binary(B) -> ok;
@@ -952,7 +936,6 @@ v_type_string(S, Path, _TrUserData) when is_list(S); is_binary(S) ->
v_type_string(X, Path, _TrUserData) -> mk_type_error(bad_unicode_string, X, Path).
-compile({nowarn_unused_function,v_type_bytes/3}).
--dialyzer({nowarn_function,v_type_bytes/3}).
v_type_bytes(B, _Path, _TrUserData) when is_binary(B) -> ok;
v_type_bytes(B, _Path, _TrUserData) when is_list(B) -> ok;
v_type_bytes(X, Path, _TrUserData) -> mk_type_error(bad_binary_value, X, Path).
@@ -965,9 +948,8 @@ mk_type_error(Error, ValueSeen, Path) ->
-compile({nowarn_unused_function,prettify_path/1}).
--dialyzer({nowarn_function,prettify_path/1}).
prettify_path([]) -> top_level;
-prettify_path(PathR) -> lists:append(lists:join(".", lists:map(fun atom_to_list/1, lists:reverse(PathR)))).
+prettify_path(PathR) -> string:join(lists:map(fun atom_to_list/1, lists:reverse(PathR)), ".").
-compile({nowarn_unused_function,id/2}).
diff --git a/src/hex_pb_signed.erl b/src/hex_pb_signed.erl
index 8258f2a..9e2a74a 100644
--- a/src/hex_pb_signed.erl
+++ b/src/hex_pb_signed.erl
@@ -63,15 +63,9 @@
-type '$msg'() :: 'Signed'().
-export_type(['$msg_name'/0, '$msg'/0]).
--if(?OTP_RELEASE >= 24).
--dialyzer({no_underspecs, encode_msg/2}).
--endif.
-spec encode_msg('$msg'(), '$msg_name'()) -> binary().
encode_msg(Msg, MsgName) when is_atom(MsgName) -> encode_msg(Msg, MsgName, []).
--if(?OTP_RELEASE >= 24).
--dialyzer({no_underspecs, encode_msg/3}).
--endif.
-spec encode_msg('$msg'(), '$msg_name'(), list()) -> binary().
encode_msg(Msg, MsgName, Opts) ->
verify_msg(Msg, MsgName, Opts),
@@ -359,7 +353,6 @@ verify_msg(Msg, MsgName, Opts) ->
-compile({nowarn_unused_function,v_msg_Signed/3}).
--dialyzer({nowarn_function,v_msg_Signed/3}).
v_msg_Signed(#{payload := F1} = M, Path, TrUserData) ->
v_type_bytes(F1, [payload | Path], TrUserData),
case M of
@@ -376,7 +369,6 @@ v_msg_Signed(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fiel
v_msg_Signed(X, Path, _TrUserData) -> mk_type_error({expected_msg, 'Signed'}, X, Path).
-compile({nowarn_unused_function,v_type_bytes/3}).
--dialyzer({nowarn_function,v_type_bytes/3}).
v_type_bytes(B, _Path, _TrUserData) when is_binary(B) -> ok;
v_type_bytes(B, _Path, _TrUserData) when is_list(B) -> ok;
v_type_bytes(X, Path, _TrUserData) -> mk_type_error(bad_binary_value, X, Path).
@@ -389,9 +381,8 @@ mk_type_error(Error, ValueSeen, Path) ->
-compile({nowarn_unused_function,prettify_path/1}).
--dialyzer({nowarn_function,prettify_path/1}).
prettify_path([]) -> top_level;
-prettify_path(PathR) -> lists:append(lists:join(".", lists:map(fun atom_to_list/1, lists:reverse(PathR)))).
+prettify_path(PathR) -> string:join(lists:map(fun atom_to_list/1, lists:reverse(PathR)), ".").
-compile({nowarn_unused_function,id/2}).
diff --git a/src/hex_pb_versions.erl b/src/hex_pb_versions.erl
index 0bade1b..6e98d36 100644
--- a/src/hex_pb_versions.erl
+++ b/src/hex_pb_versions.erl
@@ -69,15 +69,9 @@
-type '$msg'() :: 'Versions'() | 'Package'().
-export_type(['$msg_name'/0, '$msg'/0]).
--if(?OTP_RELEASE >= 24).
--dialyzer({no_underspecs, encode_msg/2}).
--endif.
-spec encode_msg('$msg'(), '$msg_name'()) -> binary().
encode_msg(Msg, MsgName) when is_atom(MsgName) -> encode_msg(Msg, MsgName, []).
--if(?OTP_RELEASE >= 24).
--dialyzer({no_underspecs, encode_msg/3}).
--endif.
-spec encode_msg('$msg'(), '$msg_name'(), list()) -> binary().
encode_msg(Msg, MsgName, Opts) ->
verify_msg(Msg, MsgName, Opts),
@@ -518,7 +512,6 @@ verify_msg(Msg, MsgName, Opts) ->
-compile({nowarn_unused_function,v_msg_Versions/3}).
--dialyzer({nowarn_function,v_msg_Versions/3}).
v_msg_Versions(#{repository := F2} = M, Path, TrUserData) ->
case M of
#{packages := F1} ->
@@ -540,11 +533,9 @@ v_msg_Versions(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fi
v_msg_Versions(X, Path, _TrUserData) -> mk_type_error({expected_msg, 'Versions'}, X, Path).
-compile({nowarn_unused_function,v_submsg_Package/3}).
--dialyzer({nowarn_function,v_submsg_Package/3}).
v_submsg_Package(Msg, Path, TrUserData) -> v_msg_Package(Msg, Path, TrUserData).
-compile({nowarn_unused_function,v_msg_Package/3}).
--dialyzer({nowarn_function,v_msg_Package/3}).
v_msg_Package(#{name := F1} = M, Path, TrUserData) ->
v_type_string(F1, [name | Path], TrUserData),
case M of
@@ -576,13 +567,11 @@ v_msg_Package(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fie
v_msg_Package(X, Path, _TrUserData) -> mk_type_error({expected_msg, 'Package'}, X, Path).
-compile({nowarn_unused_function,v_type_int32/3}).
--dialyzer({nowarn_function,v_type_int32/3}).
v_type_int32(N, _Path, _TrUserData) when is_integer(N), -2147483648 =< N, N =< 2147483647 -> ok;
v_type_int32(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, int32, signed, 32}, N, Path);
v_type_int32(X, Path, _TrUserData) -> mk_type_error({bad_integer, int32, signed, 32}, X, Path).
-compile({nowarn_unused_function,v_type_string/3}).
--dialyzer({nowarn_function,v_type_string/3}).
v_type_string(S, Path, _TrUserData) when is_list(S); is_binary(S) ->
try unicode:characters_to_binary(S) of
B when is_binary(B) -> ok;
@@ -600,9 +589,8 @@ mk_type_error(Error, ValueSeen, Path) ->
-compile({nowarn_unused_function,prettify_path/1}).
--dialyzer({nowarn_function,prettify_path/1}).
prettify_path([]) -> top_level;
-prettify_path(PathR) -> lists:append(lists:join(".", lists:map(fun atom_to_list/1, lists:reverse(PathR)))).
+prettify_path(PathR) -> string:join(lists:map(fun atom_to_list/1, lists:reverse(PathR)), ".").
-compile({nowarn_unused_function,id/2}). any idea why this might be? perhaps I ended up with different gpb version or something? something we should have done long time ago is verifying we're re-generating pb files on CI and there is no diff, so I'm keen on doing that after this lands. |
My guess is that this would likely depend on the OTP version used to build them. Our oldest builds in here are on OTP 21, so if it uses and OTP 21 target it's unlikely to get the special OTP-24 clauses and checks in there? But I'm not super familiar with the mechanism in play. |
Sounds good, I'll look into regenerating these on OTP 21 and adding CI check soon. |
I've tried to re-vendor v0.10.0 in Rebar3 this week and the build was impossible to complete without bumping these two dependencies.
This PR has three commits:
I'm not sure about the safety of 2), but 1) was required to get things working.