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

refactor(python)!: Remove re-export of type aliases #17032

Merged
merged 8 commits into from
Jun 18, 2024
Merged

Conversation

stinodego
Copy link
Member

@stinodego stinodego commented Jun 17, 2024

Changes

  • Remove re-export of PolarsDataType at the top-level
  • Remove the following re-exports in the datatypes module:
    • OneOrMoreDataTypes
    • PolarsDataType
    • PolarsTemporalType
    • PythonDataType
    • SchemaDefinition
    • SchemaDict

We do not want to re-export type aliases for a few reasons:

  • Re-exporting these means we need to load them on every import, when they are only useful during type checking.
  • So far, these aren't really meant to be public. They are meant for our own use. We haven't really vetted these to be suitable for public use.

I want to set up a proper polars.typing module like NumPy has, with a few 'blessed' type aliases. Until then, users are encouraged to define their own type aliases, or use the polars.type_aliases module though this module is not intended to be public and may be changed at any point.

This is technically not breaking because we do not document the type aliases in the API reference, but all the same, there will probably be some people who were using these re-exports. So now with the 1.0.0 release it's a good opportunity to make this change.

Example

Before:

def foo(dtype: pl.PolarsDataType) -> None: ...

After:

PolarsDataType = pl.DataType | type[pl.DataType]

def foo(dtype: PolarsDataType) -> None: ...

@github-actions github-actions bot added breaking Change that breaks backwards compatibility internal An internal refactor or improvement python Related to Python Polars labels Jun 17, 2024
@stinodego stinodego marked this pull request as ready for review June 17, 2024 21:29
Copy link

codecov bot commented Jun 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.01%. Comparing base (a62ab75) to head (c18b54f).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #17032      +/-   ##
==========================================
+ Coverage   80.98%   81.01%   +0.02%     
==========================================
  Files        1448     1448              
  Lines      190551   190547       -4     
  Branches     2723     2723              
==========================================
+ Hits       154322   154366      +44     
+ Misses      35726    35678      -48     
  Partials      503      503              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@stinodego stinodego added this to the 1.0.0 milestone Jun 17, 2024
@ritchie46 ritchie46 merged commit 2aec475 into main Jun 18, 2024
16 checks passed
@ritchie46 ritchie46 deleted the typing-module branch June 18, 2024 12:44
@c-peters c-peters added the accepted Ready for implementation label Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted Ready for implementation breaking Change that breaks backwards compatibility internal An internal refactor or improvement python Related to Python Polars
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants