@@ -88,8 +88,20 @@ def update_version_cargo_toml(cargo_toml, new_version):
88
88
89
89
for section in ("dependencies" , "dev-dependencies" ):
90
90
for (dep_name , constraint ) in doc .get (section , {}).items ():
91
- if dep_name in ("arrow" , "parquet" , "arrow-flight" ) and constraint .get ("version" ) is not None :
92
- doc [section ][dep_name ]["version" ] = new_version
91
+ if dep_name in ("arrow" , "parquet" , "arrow-flight" ):
92
+ if type (constraint ) == tomlkit .items .String :
93
+ # handle constraint that is (only) a string like '12',
94
+ doc [section ][dep_name ] = new_version
95
+ elif type (constraint ) == dict :
96
+ # handle constraint that is itself a struct like
97
+ # {'version': '12', 'features': ['prettyprint']}
98
+ doc [section ][dep_name ]["version" ] = new_version
99
+ elif type (constraint ) == tomlkit .items .InlineTable :
100
+ # handle constraint that is itself a struct like
101
+ # {'version': '12', 'features': ['prettyprint']}
102
+ doc [section ][dep_name ]["version" ] = new_version
103
+ else :
104
+ print ("Unknown type for {} {}: {}" , dep_name , constraint , type (constraint ))
93
105
94
106
with open (cargo_toml , 'w' ) as f :
95
107
f .write (tomlkit .dumps (doc ))
0 commit comments