@@ -46,6 +46,7 @@ def main(
4646 custom_visitors : Optional [List [Path ]] = typer .Option (
4747 None , "--custom-visitor" , "-c"
4848 ),
49+ disable_timestamp : bool = typer .Option (False , "--disable-timestamp" ),
4950) -> None :
5051 input_name : str = input_file .name
5152 input_text : str = input_file .read ()
@@ -61,6 +62,7 @@ def main(
6162 template_dir ,
6263 model_path ,
6364 enum_field_as_literal ,
65+ disable_timestamp = disable_timestamp ,
6466 )
6567 return generate_code (
6668 input_name ,
@@ -69,6 +71,7 @@ def main(
6971 template_dir ,
7072 model_path ,
7173 custom_visitors = custom_visitors ,
74+ disable_timestamp = disable_timestamp ,
7275 )
7376
7477
@@ -90,6 +93,7 @@ def generate_code(
9093 model_path : Optional [Path ] = None ,
9194 enum_field_as_literal : Optional [str ] = None ,
9295 custom_visitors : Optional [List [Path ]] = [],
96+ disable_timestamp : bool = False ,
9397) -> None :
9498 if not model_path :
9599 model_path = MODEL_PATH
@@ -148,8 +152,9 @@ def generate_code(
148152 timestamp = datetime .now (timezone .utc ).replace (microsecond = 0 ).isoformat ()
149153 header = f"""\
150154 # generated by fastapi-codegen:
151- # filename: { Path (input_name ).name }
152- # timestamp: { timestamp } """
155+ # filename: { Path (input_name ).name } """
156+ if not disable_timestamp :
157+ header += f"\n # timestamp: { timestamp } "
153158
154159 for path , code in results .items ():
155160 with output_dir .joinpath (path .with_suffix (".py" )).open ("wt" ) as file :
@@ -160,8 +165,8 @@ def generate_code(
160165 header = f'''\
161166 # generated by fastapi-codegen:
162167# filename: {{filename}}'''
163- # if not disable_timestamp:
164- header += f'\n # timestamp: { timestamp } '
168+ if not disable_timestamp :
169+ header += f'\n # timestamp: { timestamp } '
165170
166171 for path , body_and_filename in modules .items ():
167172 body , filename = body_and_filename
0 commit comments