uranusjr commented on code in PR #33780:
URL: https://github.com/apache/airflow/pull/33780#discussion_r1307004230


##########
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:
   The above only fails because you didn’t provide `from __future__ import 
annotations`. You probably meant to illustrate something like this instead:
   
   ```python
   from __future__ import annotations
   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]
   
   Delivery(timestamp="2023-08-28", dimentions=(2, 3))
   ```
   
   ```
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
       Delivery(timestamp="2023-08-28", dimentions=(2, 3))
     File "pydantic/main.py", line 404, in __init__
       values, fields_set, validation_error = 
validate_model(__pydantic_self__.__class__, data)
     File "pydantic/main.py", line 1040, in validate_model
       v_, errors_ = field.validate(value, values, loc=field.alias, cls=cls_)
     File "pydantic/fields.py", line 699, in validate
       raise ConfigError(
   pydantic.errors.ConfigError: field "timestamp" not yet prepared so type is 
still a ForwardRef, you might need to call Delivery.update_forward_refs().
   ```



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