Fix return type annotation of PyRanges.__new__ to enable method chaining in static type checkers - #170
Open
adamgayoso wants to merge 1 commit into
Open
Fix return type annotation of PyRanges.__new__ to enable method chaining in static type checkers#170adamgayoso wants to merge 1 commit into
adamgayoso wants to merge 1 commit into
Conversation
…ing in static type checkers (PyRanges instead of PyRanges | pd.DataFrame)
Collaborator
|
I will have a look |
Collaborator
|
I do not remember why I wrote it like this. I wonder if this was due to the return type sometimes actually being pd.DataFrame (when Chromosome, Start, or End is missing). This is actually bad design. I should throw an Error instead. I think I thought that it would break LSP if I did not support this but I was confused. Written before I had LLMs to discuss with. Will check that tests pass and do a minor version bump also. |
Collaborator
|
Ok, so I am getting back into the groove and it seems like we intentionally want it to be PyRanges | DataFrame so that e.g. returns a DataFrame. |
Collaborator
|
See #171 |
Author
|
Thanks, #171 looks good to me. |
Collaborator
|
Type checks fail. Will need to find the time to work on this. Perhaps Sunday? |
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.
Currently,
PyRanges.__new__is annotated as returningpr.PyRanges | pd.DataFrame. When a user instantiates a PyRanges object:Because PyRanges inherits from DataFrame, any function expecting a DataFrame already accepts a PyRanges instance without needing
| pd.DataFramein the annotation.