houqp commented on a change in pull request #9273:
URL: https://github.com/apache/airflow/pull/9273#discussion_r439757664



##########
File path: airflow/api_connexion/endpoints/variable_endpoint.py
##########
@@ -14,41 +14,76 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
+from typing import Optional
 
-# TODO(mik-laj): We have to implement it.
-#     Do you want to help? Please look at: 
https://github.com/apache/airflow/issues/8142
+from flask import Response, make_response, request
+from marshmallow import ValidationError
 
+from airflow.api_connexion.exceptions import BadRequest, NotFound
+from airflow.api_connexion.schemas.variable_schema import 
variable_collection_schema, variable_schema
+from airflow.models import Variable
+from airflow.utils.session import provide_session
 
-def delete_variable():
+
+def delete_variable(variable_key: str) -> Response:
     """
     Delete variable
     """
-    raise NotImplementedError("Not implemented yet.")
+    Variable.delete(variable_key)
+    return make_response('', 204)

Review comment:
       The method has return type annotated as `Response`, so it's better to 
return a Response object for type safety. The NoContent object in connexion is 
an unnecessary abstraction IMO, it's just defined as `object()`, which has the 
same effect as `''` when used in the tuple as response pattern. But it will 
result in an exception when passed to `make_response` function. That's why in 
Flask it's more common to return `''`.
   
   I have simplified this code further to just return `Response(status=204)` to 
avoid calling `make_response`.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to