refactor: Use ._with_* for internal API methods#2305
Merged
MarcoGorelli merged 10 commits intomainfrom Mar 27, 2025
Merged
Conversation
Member
Author
|
Thought I'd try and rip the bandage off quickly to resolve this - hope that's okay 🙂 |
dangotbanned
commented
Mar 27, 2025
Comment on lines
17
to
58
| def keep(self: Self) -> DaskExpr: | ||
| return self._from_alias_output_names(alias_output_names=None) | ||
| return self._with_alias_output_names(alias_output_names=None) | ||
|
|
||
| def map(self: Self, function: Callable[[str], str]) -> DaskExpr: | ||
| return self._from_alias_output_names( | ||
| return self._with_alias_output_names( | ||
| alias_output_names=lambda output_names: [ | ||
| function(str(name)) for name in output_names | ||
| ], | ||
| ) | ||
|
|
||
| def prefix(self: Self, prefix: str) -> DaskExpr: | ||
| return self._from_alias_output_names( | ||
| return self._with_alias_output_names( | ||
| alias_output_names=lambda output_names: [ | ||
| f"{prefix}{output_name}" for output_name in output_names | ||
| ], | ||
| ) | ||
|
|
||
| def suffix(self: Self, suffix: str) -> DaskExpr: | ||
| return self._from_alias_output_names( | ||
| return self._with_alias_output_names( | ||
| alias_output_names=lambda output_names: [ | ||
| f"{output_name}{suffix}" for output_name in output_names | ||
| ] | ||
| ) | ||
|
|
||
| def to_lowercase(self: Self) -> DaskExpr: | ||
| return self._from_alias_output_names( | ||
| return self._with_alias_output_names( | ||
| alias_output_names=lambda output_names: [ | ||
| str(name).lower() for name in output_names | ||
| ], | ||
| ) | ||
|
|
||
| def to_uppercase(self: Self) -> DaskExpr: | ||
| return self._from_alias_output_names( | ||
| return self._with_alias_output_names( | ||
| alias_output_names=lambda output_names: [ | ||
| str(name).upper() for name in output_names | ||
| ] | ||
| ) | ||
|
|
||
| def _from_alias_output_names( | ||
| def _with_alias_output_names( | ||
| self: Self, | ||
| alias_output_names: Callable[[Sequence[str]], Sequence[str]] | None, | ||
| ) -> DaskExpr: |
Member
Author
There was a problem hiding this comment.
Note
Pretty sure all the LazyExprNameNamespaces can share something like EagerExprNameNamespace
dangotbanned
added a commit
that referenced
this pull request
Mar 28, 2025
10 tasks
MarcoGorelli
pushed a commit
that referenced
this pull request
Mar 28, 2025
* refactor: Generalize `EagerExprNameNamespace` Follow-up to #2305 (comment) * refactor: Simplify lazy `*ExprNameNamespace` Already a nice reduction, but I think I can go further 😏 * refactor: begone `expr_name.py`
10 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Closes #2248
What type of PR is this? (check all applicable)
Related issues
(_?)with_for "this, but withxchanged" #2248Checklist
If you have comments or can explain your changes, please do so below