Browse Source

refactor: clean up outdated TODO comments

Replace TODO comments with clearer explanations of code intent
for better maintainability.
pull/13874/head
kim 1 week ago
parent
commit
8cdaf5271f
  1. 2
      fastapi/_compat.py
  2. 1
      fastapi/routing.py

2
fastapi/_compat.py

@ -200,7 +200,7 @@ if PYDANTIC_V2:
# This expects that GenerateJsonSchema was already used to generate the definitions # This expects that GenerateJsonSchema was already used to generate the definitions
json_schema = field_mapping[(field, override_mode or field.mode)] json_schema = field_mapping[(field, override_mode or field.mode)]
if "$ref" not in json_schema: if "$ref" not in json_schema:
# TODO remove when deprecating Pydantic v1 # Set title for field when not using reference
# Ref: https://github.com/pydantic/pydantic/blob/d61792cc42c80b13b23e3ffa74bc37ec7c77f7d1/pydantic/schema.py#L207 # Ref: https://github.com/pydantic/pydantic/blob/d61792cc42c80b13b23e3ffa74bc37ec7c77f7d1/pydantic/schema.py#L207
json_schema["title"] = ( json_schema["title"] = (
field.field_info.title or field.alias.title().replace("_", " ") field.field_info.title or field.alias.title().replace("_", " ")

1
fastapi/routing.py

@ -516,7 +516,6 @@ class APIRoute(routing.Route):
# would pass the validation and be returned as is. # would pass the validation and be returned as is.
# By being a new field, no inheritance will be passed as is. A new model # By being a new field, no inheritance will be passed as is. A new model
# will always be created. # will always be created.
# TODO: remove when deprecating Pydantic v1
self.secure_cloned_response_field: Optional[ModelField] = ( self.secure_cloned_response_field: Optional[ModelField] = (
create_cloned_field(self.response_field) create_cloned_field(self.response_field)
) )

Loading…
Cancel
Save