Repository navigation
Enhance model.branches and result.Iterations typing - #4767
Merged
Merged
Conversation
model.branches now takes an additional `branchtype` type parameter result.iterations now takes an additional `iterationtype` parameter
pekkaklarck
requested changes
May 22, 2023
| B = TypeVar('B', bound='Break') | ||
| M = TypeVar('M', bound='Message') | ||
| E = TypeVar('E', bound='Error') | ||
| BT = TypeVar('BT', 'IfBranch', 'TryBranch') |
Member
There was a problem hiding this comment.
TypeVar('X', bound=xxx)andTypeVar('X', xxx)have different semantic. I believe this should beTypeVar('BT', bound='IfBranch|TryBranch'). If not, thenboundprobably should be removed from others as well.- Perhaps
TI, from first letters ofTryBranchandIfBranch, would be better name thanBT. It would also be better thanITthat looks like a short version ofIteration.
|
|
||
|
|
||
| class Branches(BaseBranches['Keyword', 'For', 'While', 'If', 'Try', 'Return', 'Continue', | ||
| 'Break', 'Message', 'Error', BT]): |
Member
There was a problem hiding this comment.
Second row of the class declaration is misaligned.
|
|
||
| class Branches(model.Branches): | ||
| class Branches(model.BaseBranches['Keyword', 'For', 'While', 'If', 'Try', 'Return', | ||
| 'Continue', 'Break', 'Message', 'Error', BT]): |
Member
There was a problem hiding this comment.
Why BT is used here instead of 'IfBranch', 'TryBranch'?
Contributor
Author
There was a problem hiding this comment.
The final parameter is passed in on the If and Try class
branch_class = IfBranch
branches_class = Branches[branch_class]branch_class = TryBranch
branches_class = Branches[branch_class]| if TYPE_CHECKING: | ||
| from robot.model import Keyword, Message | ||
|
|
||
| BT = TypeVar('BT', 'IfBranch', 'TryBranch') |
Member
There was a problem hiding this comment.
See earlier comments about bound usage and naming.
| from .suiteteardownfailed import SuiteTeardownFailed, SuiteTeardownFailureHandler | ||
|
|
||
| BT = TypeVar('BT', 'IfBranch', 'TryBranch') | ||
| IT = TypeVar('IT', 'ForIteration', 'WhileIteration') |
Member
There was a problem hiding this comment.
See earlier comments about bound usage and naming. If we'd use TI instead of BT, then IT here could be FW or WF. Perhaps the latter would be better because the former looks like an abbreviation of Framework.
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.
re-named
model.Branchestomodel.BaseBranchesmodel.BaseBranchesnow takes an additionalBranchTypetype parameterresult.Iterationsnow takes an additionalIterationTypeparameterIf branch

try branch

for Iteration

while Iteration
