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


##########
airflow/utils/pydantic.py:
##########
@@ -24,19 +24,15 @@
 
 from __future__ import annotations
 
+from importlib.metadata import PackageNotFoundError, version
 
-def is_pydantic_2_installed() -> bool:
-    import sys
+from pkg_resources import parse_version

Review Comment:
   Ah no - this is exactly why I do not like `import as` and illustrates why 
you should not use it usually.
   
   When you copy-paste code, you might accidentally miss that there is also an 
`import as` to be copied.  Unless those are well known `as` (like `np` or `pd`) 
I have personally a strong preference of not using `import as` - mostly because 
they require you to always look at two - usually very far away from each other 
- places in the python file to understand what's going on `really'. I replaced 
it all with module imports and prefixing the modules where the generic 
`version` or `parse` are used. That's way less ambiguous.



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