Skip to content

Conversation

@SadeghPouriyanZadeh
Copy link

Summary

Add a stub for pandas.io.sql.get_schema. The function exists at runtime but
is missing from the pandas-stubs, causing Pylance/Pyright to report:

"get_schema" is unknown import symbol (reportAttributeAccessIssue)

Rationale

  • Improves developer experience in VS Code / Pyright without changing pandas runtime.
  • Keeps pandas’ API policy unchanged (no need to modify pandas or __all__).

Signature

def get_schema(
    frame: DataFrame,
    name: str,
    keys: str | Sequence[str] | None = ...,
    con: Any = ...,
    dtype: DtypeArg | None = ...,
    schema: str | None = ...,
) -> str: ...

@cmp0xff
Copy link
Contributor

cmp0xff commented Nov 10, 2025

This function is mentioned nowhere else in the docs except for What's new's. If it is indeed internal, we will not include it in the stubs. @Dr-Irv could you confirm?

@cmp0xff cmp0xff added the Closing Candidate May be closeable, needs more eyeballs label Nov 10, 2025
@SadeghPouriyanZadeh
Copy link
Author

I'm using it via pandas.io.sql. Does it help?

@cmp0xff
Copy link
Contributor

cmp0xff commented Nov 10, 2025

Thank you for following up. I understand that you use pandas.io.sql.get_schema and that adding it to stubs could be helpful.

I would like to refer to README.md, where it states

The https://github.com/pandas-dev/pandas-stubs/ project provides type declarations for the pandas public API.

@SadeghPouriyanZadeh
Copy link
Author

Thanks. I haven't read that part. I get it now. I thought internal APIs are included too.

@Dr-Irv
Copy link
Collaborator

Dr-Irv commented Nov 10, 2025

This function is mentioned nowhere else in the docs except for What's new's. If it is indeed internal, we will not include it in the stubs. @Dr-Irv could you confirm?

Yes, I confirm.

Having said that, there is a 10-year old issue in pandas discussing whether this should be documented. See pandas-dev/pandas#9960

Once that is resolved, we could add it in pandas-stubs

@SadeghPouriyanZadeh
Copy link
Author

@Dr-Irv thanks for your comment. I didn't know the history of get_schema. I commented there and I happily hope they decide sooner. Because this feature is fundamental to AI RAG use cases. Thanks again 🙏

@cmp0xff
Copy link
Contributor

cmp0xff commented Nov 10, 2025

I'll close the MR for now. Please ping us here if the function gets published.

@cmp0xff cmp0xff closed this Nov 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Closing Candidate May be closeable, needs more eyeballs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants