Closed lewisjared closed 1 year ago
I'm going to follow this MR with a rework of the typing for all public functions. A lot of functions also return Self
and aren't currently typed as such
Patch coverage: 100.00
% and project coverage change: +0.03
:tada:
Comparison is base (
753e83f
) 95.77% compared to head (b7f45bb
) 95.81%.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
Check out this pull request on
See visual diffs & provide feedback on Jupyter Notebooks.
Powered by ReviewNB
res will have an inferred type of
ScmRun | BaseScmRun
rather than the expectedScmRun
. Not perfect, but if we type it as a tuple we can differentiate the first type vs the rest. @mikapfl you might have a better solution for this.
Hmm tricky. I could live with the tuple requirement (I assume that just using Iterable or Sequence or something doesn't solve our problem?), but also interested to hear what @mikapfl thinks as my typing experience is limited.
I think the Iterable[T]
is fine. It is correct that it leads to wrong mixed inferred types for the run_append([ScmRun, BaseScmRun])
call, but, honestly, that is borderline incorrect usage anyway, I think. What is the use case for concatenating mixed types here?
Updates operations that could be performed inplace to always return an ScmRun. The
inplace
argument dictates whether it is a copy or not.This also fixes a typing issue for
run_append
which had a return type ofBaseScmRun | None
. It now returns the type of the items that are being appended.The current implementation isn't perfect, as I don't believe you differentiate the type for the first item vs the rest of the list. Python assumes that a list has a homogenous type which results in a mixed type list being typed as
list[A | B]
.For example:
res will have an inferred type of
ScmRun | BaseScmRun
rather than the expectedScmRun
. Not perfect, but if we type it as a tuple we can differentiate the first type vs the rest. @mikapfl you might have a better solution for this.Typing as a tuple wouldn't break any functionality, but would result in type errors in downstream code.
Closes #230
Pull request
Please confirm that this pull request has done the following:
CHANGELOG.rst
addedAdding to CHANGELOG.rst
Please add a single line in the changelog notes similar to one of the following: