Skip to content
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

DOC: fix EX03 Errors for pandas.DataFrame.to_sql #56866

Closed

Conversation

erichxchen
Copy link
Contributor

Fix these EX03 Errors for pandas.DataFrame.to_sql:

9 Errors found for `pandas.DataFrame.to_sql`:
        flake8 error: line 8, col 4: E111 indentation is not a multiple of 4
        flake8 error: line 15, col 4: E111 indentation is not a multiple of 4
        flake8 error: line 19, col 4: E111 indentation is not a multiple of 4
        flake8 error: line 27, col 1: F821 undefined name 'df_conflict'
        flake8 error: line 27, col 89: E501 line too long (124 > 88 characters)
        flake8 error: line 28, col 1: F811 redefinition of unused 'insert' from line 22
        flake8 error: line 39, col 1: F821 undefined name 'df_conflict'
        flake8 error: line 39, col 89: E501 line too long (123 > 88 characters)
        flake8 error: line 46, col 3: E111 indentation is not a multiple of 4

@erichxchen erichxchen requested a review from mroeschke as a code owner January 14, 2024 04:03
@erichxchen erichxchen changed the title Fix EX03 Errors for pandas.DataFrame.to_sql DOC: fix EX03 Errors for pandas.DataFrame.to_sql Jan 14, 2024
@@ -3042,7 +3042,7 @@ def to_sql(
For MySQL, a callable to update columns ``b`` and ``c`` if there's a conflict
on a primary key.

>>> from sqlalchemy.dialects.mysql import insert
>>> from sqlalchemy.dialects.mysql import insert # doctest: +SKIP
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice changes, just one comment. The error seems to suggest that insert is already imported before but never used. Can you have a look, and remove the previous import if that's really the case.

Copy link
Contributor Author

@erichxchen erichxchen Jan 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's actually used in L3036:

...     stmt = insert(table.table).values(data).on_conflict_do_nothing(index_elements=["a"])

I am not quite sure why it shows this error, but I think we could just # doctest: +SKIP this line

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, fair enough. Not sure if another option would be to remove this line. But having the skip is fine if there is no other obvious solution.

I'll resolve the conflict and let someone else review, so we have a second opinion, but this looks good to me.

@natmokval
Copy link
Contributor

natmokval commented Jan 17, 2024

@erichxchen, thank you for working on this. I think, there are some errors left that need to be fixed:

5 Errors found for `pandas.DataFrame.to_sql`:
        EX03    flake8 error: line 27, col 1: F821 undefined name 'df_conflict'
        EX03    flake8 error: line 27, col 89: E501 line too long (124 > 88 characters)
        EX03    flake8 error: line 28, col 1: F811 redefinition of unused 'insert' from line 22
        EX03    flake8 error: line 39, col 1: F821 undefined name 'df_conflict'
        EX03    flake8 error: line 39, col 89: E501 line too long (123 > 88 characters)

For example, the line

>>> df_conflict.to_sql(name="conflict_table", con=conn, if_exists="append", method=insert_on_conflict_nothing) # doctest: +SKIP

is too long. Could you please rewrite it as multi-line statement? It will fix one of the errors.

@mroeschke
Copy link
Member

Closed by #57025

@mroeschke mroeschke closed this Jan 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants