Taragolis commented on code in PR #33780: URL: https://github.com/apache/airflow/pull/33780#discussion_r1306622694
########## airflow/providers/amazon/aws/hooks/ecr.py: ########## @@ -20,11 +20,14 @@ import base64 import logging from dataclasses import dataclass -from datetime import datetime +from typing import TYPE_CHECKING from airflow.providers.amazon.aws.hooks.base_aws import AwsBaseHook from airflow.utils.log.secrets_masker import mask_secret +if TYPE_CHECKING: + from datetime import datetime Review Comment: I would be very cautions with this pre-commit validations, because it need to handle a lot of stuff the nice example is `pydantic` which use annotations in runtime , and put them under `if TYPE_CHECKING` block might lead serious problem For example lets use example from the [main page](https://docs.pydantic.dev/latest/) of `pydantic` documentation This is work fine ```python from datetime import datetime from typing import Tuple from pydantic import BaseModel class Delivery(BaseModel): timestamp: datetime dimensions: Tuple[int, int] m = Delivery(timestamp='2020-01-02T03:04:05Z', dimensions=['10', '20']) ``` and this one would fail on model compilation ```python from typing import Tuple, TYPE_CHECKING from pydantic import BaseModel if TYPE_CHECKING: from datetime import datetime class Delivery(BaseModel): timestamp: datetime dimensions: Tuple[int, int] ``` ```console /Users/taragolis/.pyenv/versions/3.9.10/envs/narrative/bin/python /Users/taragolis/Library/Application Support/JetBrains/PyCharm2023.2/scratches/pydantic_sample.py Traceback (most recent call last): File "/Users/taragolis/Library/Application Support/JetBrains/PyCharm2023.2/scratches/pydantic_sample.py", line 9, in <module> class Delivery(BaseModel): File "/Users/taragolis/Library/Application Support/JetBrains/PyCharm2023.2/scratches/pydantic_sample.py", line 10, in Delivery timestamp: datetime NameError: name 'datetime' is not defined Process finished with exit code 1 ``` -- 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]
