Skip to content

Conversation

@jscheffl
Copy link
Contributor

Relates to #53241

@gopidesupavan
Copy link
Member

some failures :)

@jscheffl
Copy link
Contributor Author

some failures :)

@gopidesupavan Here I am a bit unclear. Mypy tells me the type ignores are not needed but if I remove them I get a clash on the other check because of inconsistency between imports from task-sdk vs. airflow-core. Unsure how to fix it... we need compatability but signatures seem to be inconsistent. WDYT?
Argument 1 to "_get_conn_config_mysql_client" of "MySqlHook" has incompatible type "airflow.sdk.definitions.connection.Connection"; expected "airflow.models.connection.Connection" [arg-type]

@gopidesupavan
Copy link
Member

gopidesupavan commented Jul 13, 2025

some failures :)

@gopidesupavan Here I am a bit unclear. Mypy tells me the type ignores are not needed but if I remove them I get a clash on the other check because of inconsistency between imports from task-sdk vs. airflow-core. Unsure how to fix it... we need compatability but signatures seem to be inconsistent. WDYT? Argument 1 to "_get_conn_config_mysql_client" of "MySqlHook" has incompatible type "airflow.sdk.definitions.connection.Connection"; expected "airflow.models.connection.Connection" [arg-type]

    try:
        from airflow.sdk import Connection
    except ImportError:
        from airflow.models.connection import Connection  # type: ignore[assignment]

I think that should work? under TYPE_CHECKING block

@gopidesupavan
Copy link
Member

gopidesupavan commented Jul 13, 2025

mypy throwing error in my local here https://github.com/apache/airflow/pull/53288/files#diff-45f9fbfe948e542f1e9ab370ca2c197d2878f76bfc868b015c74665f10fcbef6R133, might cause this buggy if we get some none field. would you like to update part of this PR? or i am happy to push new pr to fix :)

providers/mysql/src/airflow/providers/mysql/hooks/mysql.py:136: error: Item
"None" of "str | Any | None" has no attribute "lower"  [union-attr]
                if conn_config["charset"].lower() in ("utf8", "utf-8"):

@jscheffl
Copy link
Contributor Author

some failures :)

@gopidesupavan Here I am a bit unclear. Mypy tells me the type ignores are not needed but if I remove them I get a clash on the other check because of inconsistency between imports from task-sdk vs. airflow-core. Unsure how to fix it... we need compatability but signatures seem to be inconsistent. WDYT? Argument 1 to "_get_conn_config_mysql_client" of "MySqlHook" has incompatible type "airflow.sdk.definitions.connection.Connection"; expected "airflow.models.connection.Connection" [arg-type]

    try:
        from airflow.sdk import Connection
    except ImportError:
        from airflow.models.connection import Connection  # type: ignore[assignment]

I think that should work? under TYPE_CHECKING block

Okay, attempted it with a proper version compat, hope this will make it green

@jscheffl
Copy link
Contributor Author

mypy throwing error in my local here https://github.com/apache/airflow/pull/53288/files#diff-45f9fbfe948e542f1e9ab370ca2c197d2878f76bfc868b015c74665f10fcbef6R133, might cause this buggy if we get some none field. would you like to update part of this PR? or i am happy to push new pr to fix :)

providers/mysql/src/airflow/providers/mysql/hooks/mysql.py:136: error: Item
"None" of "str | Any | None" has no attribute "lower"  [union-attr]
                if conn_config["charset"].lower() in ("utf8", "utf-8"):

Fixing alongside... thanks for the hint...

@jscheffl jscheffl force-pushed the bugfix/cleanup-mypy-mysql branch from 7e650ad to 8aef431 Compare July 13, 2025 09:42
@gopidesupavan
Copy link
Member

mypy throwing error in my local here https://github.com/apache/airflow/pull/53288/files#diff-45f9fbfe948e542f1e9ab370ca2c197d2878f76bfc868b015c74665f10fcbef6R133, might cause this buggy if we get some none field. would you like to update part of this PR? or i am happy to push new pr to fix :)

providers/mysql/src/airflow/providers/mysql/hooks/mysql.py:136: error: Item
"None" of "str | Any | None" has no attribute "lower"  [union-attr]
                if conn_config["charset"].lower() in ("utf8", "utf-8"):

Fixing alongside... thanks for the hint...

cool thank you ;)

@jscheffl jscheffl force-pushed the bugfix/cleanup-mypy-mysql branch from 89c87b1 to cf72696 Compare July 13, 2025 10:20
@jscheffl jscheffl merged commit 7ca3954 into apache:main Jul 13, 2025
75 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants