dazza-codes commented on a change in pull request #6811: [RFC][AIRFLOW-6245]
Add custom waiters for AWS batch jobs
URL: https://github.com/apache/airflow/pull/6811#discussion_r361009175
##########
File path: tests/test_core_to_contrib.py
##########
@@ -757,6 +757,11 @@
"airflow.providers.amazon.aws.operators.batch.AwsBatchOperator",
"airflow.contrib.operators.awsbatch_operator.AWSBatchOperator",
),
+ # # Leave this out to avoid TypeError: Instance and class checks can only
be used with @runtime protocols
+ # (
+ # "airflow.providers.amazon.aws.hooks.batch_client.AwsBatchProtocol",
+ # "airflow.contrib.operators.awsbatch_operator.BatchProtocol",
+ # ),
Review comment:
Yes, if there is a fix for testing `Protocol` but the typing system is
failing on the `issubclass` test, as noted in the comment. So the comment is a
placeholder to warn about avoiding this error, because I don't know an easy fix
for it (yet). I did some cursory research on this error and did not find an
easy solution - I did try to apply an `@runtime` decorator but that raised
other errors. I didn't want to change up the existing test method for the
sub-class check, but the changes implemented do use the subclass approach
required. It's just that a `Protocol` raises a `TypeError` in the `issubclass`
method; i.e.
```python
>>> from typing_extensions import Protocol
>>> class ProtoSubclass(Protocol):
... pass
...
>>> issubclass(ProtoSubclass, Protocol)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File
"/opt/conda/envs/airflow/lib/python3.6/site-packages/typing_extensions.py",
line 1265, in __subclasscheck__
raise TypeError("Instance and class checks can only be used with"
TypeError: Instance and class checks can only be used with @runtime protocols
>>> from typing_extensions import runtime
>>> @runtime
... class ProtoSubclass(Protocol):
... pass
...
>>> issubclass(ProtoSubclass, Protocol)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File
"/opt/conda/envs/airflow/lib/python3.6/site-packages/typing_extensions.py",
line 1265, in __subclasscheck__
raise TypeError("Instance and class checks can only be used with"
TypeError: Instance and class checks can only be used with @runtime protocols
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services