potiuk commented on code in PR #41871:
URL: https://github.com/apache/airflow/pull/41871#discussion_r1738712943


##########
airflow/providers/elasticsearch/hooks/elasticsearch.py:
##########
@@ -34,6 +34,9 @@
 
     from airflow.models.connection import Connection as AirflowConnection
 
+if "pytest" in sys.modules:
+    import elasticsearch  # noqa: F401

Review Comment:
   This sounds very strange and I would never expect to check in "prod" code 
whether pytest is in modules. That is very suspicious - what happens if someone 
does have pytest in their dependencies (for whatever reason?) I do not 
understand why this one would be needed here. It's also under TYPE_CHECKIN Why 
do you need to check for pytest here?
   
   IMHO. Way better solution will be to make "from elasticsearch import 
ElasticSearch"  local in all the methods that need it and leave import 
elasticsearch unconditionally in TYPE_CHECKING.
   



-- 
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.

To unsubscribe, e-mail: [email protected]

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

Reply via email to