Skip to content

ENH: Improve sql io api #229

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

Merged
merged 11 commits into from
Sep 3, 2022
Merged

ENH: Improve sql io api #229

merged 11 commits into from
Sep 3, 2022

Conversation

bashtage
Copy link
Contributor

  • Tests added: Please use assert_type() to assert the type of any return value

@bashtage bashtage marked this pull request as draft August 25, 2022 23:58
@bashtage
Copy link
Contributor Author

Testing this might not be worth it.

@bashtage bashtage marked this pull request as ready for review August 26, 2022 07:09
@bashtage
Copy link
Contributor Author

I included some classes and their attributes as these are required for some of the modes. These classes are used in the docs as examples.

Copy link
Collaborator

@Dr-Irv Dr-Irv left a comment

Choose a reason for hiding this comment

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

For tests, you could test the types by surrounding the tests with if TYPE_CHECKING. So then pytest won't execute them, but the type checking will still happen.

@Dr-Irv
Copy link
Collaborator

Dr-Irv commented Aug 26, 2022

One other idea. Some of the methods have types that depend on sqlalchemy. I'm pretty sure that the type checkers assume that typeshed is installed, which has sqlalchemy types defined, so it might be worth using sqlalchemy types where they are documented (e.g., the connection arguments).

@Dr-Irv
Copy link
Collaborator

Dr-Irv commented Aug 26, 2022

One other idea. Some of the methods have types that depend on sqlalchemy. I'm pretty sure that the type checkers assume that typeshed is installed, which has sqlalchemy types defined, so it might be worth using sqlalchemy types where they are documented (e.g., the connection arguments).

Or maybe easier than worrying about typeshed, make an installation dependency on sqlalchemy-stubs

@bashtage
Copy link
Contributor Author

Or maybe easier than worrying about typeshed, make an installation dependency on sqlalchemy-stubs

I went with types_SQLAlchemy which seems to be actively maintained. sqlalchemy-stubs hasn't updated in a year.

Add sqlalchemy
Fix small issues in initial pass
@Dr-Irv
Copy link
Collaborator

Dr-Irv commented Aug 30, 2022

Only issue is to add a typing test. You can do

def test_sql_types() -> None:
    df = # Some dataframe
    if TYPE_CHECKING:
        df.to_sql(# arguments)

        # additional tests

@bashtage bashtage closed this Aug 31, 2022
@bashtage bashtage reopened this Aug 31, 2022
@bashtage
Copy link
Contributor Author

Close/reopen to force CI and see if loguru happens here too.

@bashtage
Copy link
Contributor Author

bashtage commented Sep 3, 2022

Still would like a comment in the code as to why TYPE_CHECKING is used here
Comment added.

Copy link
Collaborator

@Dr-Irv Dr-Irv left a comment

Choose a reason for hiding this comment

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

thanks @bastage

@Dr-Irv Dr-Irv merged commit 4c97ed3 into pandas-dev:main Sep 3, 2022
@bashtage bashtage deleted the io-sql branch September 3, 2022 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants