potiuk commented on pull request #20409:
URL: https://github.com/apache/airflow/pull/20409#issuecomment-997934311


   > > Context is a TypedDict, which naturally downcasts to `Dict[str, Any]`.
   > 
   > I will try as you suggest
   
   It will not work as exepected because of Liskov substitution principle. 
   
   ```
   airflow/providers/apache/hive/sensors/metastore_partition.py:70: error: 
Argument 1 of "poke" is incompatible with supertype "BaseSensorOperator"; 
supertype defines the argument type as "Context"
           def poke(self, context: MutableMapping[str, Any]) -> Any:
           ^
   airflow/providers/apache/hive/sensors/metastore_partition.py:70: note: This 
violates the Liskov substitution principle
   airflow/providers/apache/hive/sensors/metastore_partition.py:70: note: See 
https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
   ```
   
   But I think I found a nice "workaround":
   
   In imports section of all operators/sensors:
   
   ```
   if TYPE_CHECKING:
       from airflow.utils.context import Context
   else:
       Context = MutableMapping[str, Any]
   ```


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