Skip to content

add casts for pandas type stub incompatibilities#517

Merged
hirosassa merged 2 commits into
m3dev:masterfrom
hirosassa:add-cast-for-pandas
May 15, 2026
Merged

add casts for pandas type stub incompatibilities#517
hirosassa merged 2 commits into
m3dev:masterfrom
hirosassa:add-cast-for-pandas

Conversation

@hirosassa

Copy link
Copy Markdown
Collaborator

SSIA

@hiro-o918

Copy link
Copy Markdown
Contributor

Regarding return pd.read_pickle(cast(Any, file)) in gokart/utils.py:

The cast(Any, ...) here could be eliminated by refining the FileLike Protocol so that it becomes a structural subtype of pandas' ReadPickleBuffer (adding mode property, tell(), and adjusting read / seek signatures). That would also require updating _ChunkedLargeFileReader in gokart/file_processor/base.py to match.

Since that's a wider change, let's keep this PR focused on the cast workaround and track the refactor separately: #521.

@hirosassa

Copy link
Copy Markdown
Collaborator Author

I agree with your suggestion. Will apply your idea in another PR.

@hirosassa hirosassa enabled auto-merge (squash) May 15, 2026 00:11
Comment thread gokart/utils.py
assert file.seekable(), f'{file} is not seekable.'
file.seek(0)
return pd.read_pickle(file)
return pd.read_pickle(cast(Any, file))

@hiro-o918 hiro-o918 May 15, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ah, how about casting to ReadPickleBuffer of pandas because some method of pandas protocol seems to be too much?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

agreed, will apply in another PR.

@hirosassa hirosassa merged commit 87ac0a5 into m3dev:master May 15, 2026
8 checks passed
@hirosassa hirosassa deleted the add-cast-for-pandas branch May 15, 2026 00:13
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