@@ -199,7 +199,7 @@ private void serializeHeaders(
199199 ) {
200200 writer .pushState (new SerializeFieldsSection (operation ));
201201 writer .addDependency (SmithyPythonDependency .SMITHY_HTTP );
202- writer .addImports ("smithy_http" , Set . of ( "Field" , " Fields") );
202+ writer .addImport ("smithy_http" , " Fields" );
203203 writer .write ("""
204204 headers = Fields(
205205 [
@@ -234,9 +234,12 @@ private void writeContentType(GenerationContext context, PythonWriter writer, Op
234234 if (optionalContentType .isEmpty () && shouldWriteDefaultBody (context , operation )) {
235235 optionalContentType = Optional .of (getDocumentContentType ());
236236 }
237- optionalContentType .ifPresent (contentType -> writer .write (
238- "Field(name=\" Content-Type\" , values=[$S])," ,
239- contentType ));
237+ if (optionalContentType .isPresent ()) {
238+ writer .addImport ("smithy_http" , "Field" );
239+ writer .write (
240+ "Field(name=\" Content-Type\" , values=[$S])," ,
241+ optionalContentType .get ());
242+ }
240243 }
241244
242245 private void writeContentLength (GenerationContext context , PythonWriter writer , OperationShape operation ) {
@@ -249,6 +252,7 @@ private void writeContentLength(GenerationContext context, PythonWriter writer,
249252 // The requiresLength trait, however, can force a length calculation.
250253 // see: https://smithy.io/2.0/spec/streaming.html#requireslength-trait
251254 if (requiresLength (context , operation )) {
255+ writer .addImport ("smithy_http" , "Field" );
252256 writer .write ("Field(name=\" Content-Length\" , values=[str(content_length)])," );
253257 }
254258 return ;
@@ -262,6 +266,7 @@ private void writeContentLength(GenerationContext context, PythonWriter writer,
262266 .anyMatch (binding -> binding .getLocation () == PAYLOAD || binding .getLocation () == DOCUMENT );
263267
264268 if (hasBodyBindings ) {
269+ writer .addImport ("smithy_http" , "Field" );
265270 writer .write ("Field(name=\" Content-Length\" , values=[str(content_length)])," );
266271 }
267272 }
@@ -331,6 +336,7 @@ private void serializeIndividualHeaders(GenerationContext context, PythonWriter
331336 headers.extend(tuples_to_fields(($S, $L) for e in input.$L$L))
332337 """ , binding .getLocationName (), inputValue , pythonName , trailer );
333338 } else {
339+ writer .addImport ("smithy_http" , "Field" );
334340 var dataSource = "input." + pythonName ;
335341 var inputValue = target .accept (new HttpMemberSerVisitor (
336342 context ,
0 commit comments