potiuk commented on code in PR #37585:
URL: https://github.com/apache/airflow/pull/37585#discussion_r1497233955
##########
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
- from packaging.version import Version
- if sys.version_info >= (3, 9):
- from importlib.metadata import distribution
- else:
- from importlib_metadata import distribution
+def is_pydantic_2_installed() -> bool:
try:
- return Version(distribution("pydantic").version) >= Version("2.0.0")
- except ImportError:
+ return parse_version(version("pydantic")).major == 2
+ except PackageNotFoundError:
Review Comment:
That is not an our method . Why do you want unit test external method ? I
guess it already has unit tests in stdlib. Can you check there ? I don't think
we shou unit tests every single method call in stdlib - I believe this is what
you suggest ?
--
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]