-
Notifications
You must be signed in to change notification settings - Fork 14.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed MyPy errors introduced by new mysql-connector-python #28995
Conversation
The new (8.0.32) mysql-connector-python introduces more typing and failed our MySQL provider mypy tests (because we are handling also other mysql clients) Adding some excludes and handling None better for description solves the problem
ff1b877
to
4a4c25f
Compare
conn.close() | ||
conn.close() # type: ignore[misc] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What error does this ignore? (Also other ignores below.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’ll look into it later, merging this first wouldn’t break anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:D I thought you will be ok with it :)
The new (8.0.32) mysql-connector-python introduces more typing and failed our MySQL provider mypy tests (because we are handling also other mysql clients)
Adding some excludes and handling None better for description solves the problem
^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named
{pr_number}.significant.rst
or{issue_number}.significant.rst
, in newsfragments.