Skip to content

Add pathlib.Path support to all IO and SQL functions - #339

Open
sitekwb wants to merge 1 commit into
biodatageeks:masterfrom
sitekwb:claude/resolve-github-issue-4x2jN
Open

Add pathlib.Path support to all IO and SQL functions#339
sitekwb wants to merge 1 commit into
biodatageeks:masterfrom
sitekwb:claude/resolve-github-issue-4x2jN

Conversation

@sitekwb

@sitekwb sitekwb commented Mar 6, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR adds support for pathlib.Path objects across all IO and SQL functions in polars-bio, resolving issue #190. Previously, only string paths were accepted; now users can pass Path objects directly to any read, scan, or register function.

Key Changes

  • Updated type hints in polars_bio/io.py to accept Union[str, Path] for all read/scan functions (read_bam, scan_bam, read_bed, scan_bed, read_vcf, scan_vcf, read_fastq, scan_fastq, read_fasta, scan_fasta, read_gff, scan_gff, read_table, scan_table, describe_vcf)
  • Updated type hints in polars_bio/sql.py to accept Union[str, Path] for all register functions (register_bam, register_bed, register_vcf, register_gff, register_fastq)
  • Added explicit path = str(path) conversions at the entry points of internal functions (_read_file, _get_schema, describe_vcf, and all register functions) to ensure Path objects are converted to strings before being passed to underlying C++ bindings
  • Added from pathlib import Path imports to both io.py and sql.py
  • Added comprehensive test suite (TestIOPathInputs) with 16 new tests covering all read, scan, and register functions with Path objects

Implementation Details

  • Path conversion is done at the function entry points rather than in every internal call, minimizing code duplication
  • The approach is backward compatible - existing code using string paths continues to work unchanged
  • All tests verify that Path objects produce identical results to their string path equivalents

https://claude.ai/code/session_01VKPcoBGRifVhJt8gR29aFt

…ks#190)

All read_*/scan_*/register_*/write_*/sink_*/describe_* methods now
accept Union[str, Path] instead of just str. Conversion str(path)
is applied at the FFI boundary in _read_file, _write_file,
_write_bam_file, and each describe_* method.

Tests added in TestIOPathInputs covering read, scan, and register
variants for BAM, BED, VCF, FASTQ, FASTA, and GFF formats.

https://claude.ai/code/session_01VKPcoBGRifVhJt8gR29aFt
@sitekwb
sitekwb force-pushed the claude/resolve-github-issue-4x2jN branch from 02cdc93 to 347cecf Compare March 7, 2026 09:06
@mwiewior

mwiewior commented Mar 7, 2026

Copy link
Copy Markdown
Collaborator

@claude pls review

@mwiewior

mwiewior commented Mar 7, 2026

Copy link
Copy Markdown
Collaborator

@codex pls review

@claude

claude Bot commented Mar 7, 2026

Copy link
Copy Markdown

Claude Code is working…

I'll analyze this and get back to you.

View job run

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@claude

claude Bot commented Mar 7, 2026

Copy link
Copy Markdown

Claude Code is working…

I'll analyze this and get back to you.

View job run

@sitekwb

sitekwb commented Mar 9, 2026

Copy link
Copy Markdown
Contributor Author

@mwiewior Something to fix here or we can merge?

@mwiewior

mwiewior commented Mar 9, 2026

Copy link
Copy Markdown
Collaborator

Need to review it first.

@mwiewior

Copy link
Copy Markdown
Collaborator

@codex pls review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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.

3 participants