potiuk commented on code in PR #28995:
URL: https://github.com/apache/airflow/pull/28995#discussion_r1073133894
##########
airflow/providers/apache/hive/transfers/mysql_to_hive.py:
##########
@@ -143,12 +143,13 @@ def execute(self, context: Context):
encoding="utf-8",
)
field_dict = OrderedDict()
- for field in cursor.description:
- field_dict[field[0]] = self.type_map(field[1])
+ if cursor.description is not None:
+ for field in cursor.description:
+ field_dict[field[0]] = self.type_map(field[1])
csv_writer.writerows(cursor)
f.flush()
cursor.close()
- conn.close()
+ conn.close() # type: ignore[misc]
Review Comment:
See
https://github.com/apache/airflow/actions/runs/3943690729/jobs/6749107020 for
example:
```
airflow/providers/mysql/hooks/mysql.py:81: error: "bool" not callable
[operator]
conn.autocommit(autocommit)
^
airflow/providers/mysql/hooks/mysql.py:96: error: Item
"MySQLConnectionAbstract" of "Union[Any, MySQLConnectionAbstract]" has no
attribute "get_autocommit" [union-attr]
return conn.get_autocommit()
^
airflow/providers/mysql/hooks/mysql.py:202: error: Attribute function "close"
with type "Callable[[], Any]" does not accept self argument [misc]
conn.close()
^
airflow/providers/mysql/hooks/mysql.py:215: error: Attribute function "close"
with type "Callable[[], Any]" does not accept self argument [misc]
conn.close()
^
airflow/providers/mysql/hooks/mysql.py:286: error: Attribute function "close"
with type "Callable[[], Any]" does not accept self argument [misc]
conn.close()
^
airflow/providers/apache/hive/transfers/mysql_to_hive.py:[146](https://github.com/apache/airflow/actions/runs/3943690729/jobs/6749107020#step:6:147):
error: Item
"None" of
"Union[Any, List[Tuple[str, int, None, None, None, None, Union[bool, int],
int, int]], None]"
has no attribute "__iter__" (not iterable) [union-attr]
for field in cursor.description:
^
airflow/providers/apache/hive/transfers/mysql_to_hive.py:151: error:
Attribute
function "close" with type "Callable[[], Any]" does not accept self argument
[misc]
conn.close()
^
Found 7 errors in 2 files (checked 930 source files)
```
I **thiink** it is a wrong typing coming from bad interpretation of our
MySQL union typing. I have not figured out how to do it "properly" - but if you
have an idea how to fix it better - I am all ears.
--
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]