Skip to content

Conversation

@MarcoGorelli
Copy link
Collaborator

@MarcoGorelli MarcoGorelli commented Sep 27, 2025

Non-Python-literal input are already allowed here, I think the type hints just didn't get updated in #4516 ?

I've updated to match how it's typed in extract:

def extract(self, pattern: IntoExprColumn, group_index: int = 1) -> Series:

def extract(self, pattern: IntoExprColumn, group_index: int = 1) -> Expr:

@github-actions github-actions bot added fix Bug fix python Related to Python Polars labels Sep 27, 2025
@MarcoGorelli MarcoGorelli changed the title fix(python): Allow for non-python-literal input in str.replace and str.replace_all fix(python): Allow for IntoExprColumn arguments in str.replace and str.replace_all Sep 27, 2025
@MarcoGorelli MarcoGorelli marked this pull request as ready for review September 27, 2025 17:32
@MarcoGorelli MarcoGorelli changed the title fix(python): Allow for IntoExprColumn arguments in str.replace and str.replace_all fix(python): Allow for IntoExprColumn arguments in serie.str.replace and series.str.replace_all Sep 27, 2025
@MarcoGorelli MarcoGorelli changed the title fix(python): Allow for IntoExprColumn arguments in serie.str.replace and series.str.replace_all fix(python): Allow for IntoExprColumn arguments in series.str.replace and series.str.replace_all Sep 27, 2025
@MarcoGorelli MarcoGorelli changed the title fix(python): Allow for IntoExprColumn arguments in series.str.replace and series.str.replace_all fix(python): Allow for IntoExprColumn arguments in Series.str.replace and Series.str.replace_all Sep 27, 2025
@codecov
Copy link

codecov bot commented Sep 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.71%. Comparing base (1306208) to head (e490df3).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #24644      +/-   ##
==========================================
- Coverage   81.71%   81.71%   -0.01%     
==========================================
  Files        1700     1700              
  Lines      233283   233283              
  Branches     2996     2996              
==========================================
- Hits       190633   190617      -16     
- Misses      41888    41904      +16     
  Partials      762      762              

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@coastalwhite
Copy link
Collaborator

I think IntoExprColumn is the wrong annotation here.

IntoExprColumn means "Inputs that can convert into a col expression". That is not the case here. The str here semantically means a string, not a column identifier.

@MarcoGorelli
Copy link
Collaborator Author

Sure, this is one of the cases with str_as_lit=True

It's the same in offset_by, which uses str | IntoExprColumn

def offset_by(self, by: str | IntoExprColumn) -> Series:

Would that be acceptable?

@coastalwhite
Copy link
Collaborator

I think that indeed makes sense and is acceptable.

@mcrumiller
Copy link
Contributor

mcrumiller commented Oct 1, 2025

It's the same in offset_by, which uses str | IntoExprColumn

I am confused by this, if you have a column named "1y" then what happens when you pass offset_by("1y")?

@MarcoGorelli
Copy link
Collaborator Author

Then it would be interpreted as a string literal "1 year"

@mcrumiller
Copy link
Contributor

Then it would be interpreted as a string literal "1 year"

Is this a priority issue then? It first tries to interpret as literal string, then as an column-convertible expression? Maybe I don't understand IntoExprColumn.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Bug fix python Related to Python Polars

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants