Repository navigation
Keyword visibility modifiers for resource files (#430) - #4345
Conversation
…eyword with the same name
… private keywords with the same name
…in the same namespace
|
Hi @pekkaklarck , just a quick reminder that this PR is ready for code review |
pekkaklarck
left a comment
There was a problem hiding this comment.
Looks great! Implementation is good, there are comprehensive tests, and also documentation has been updated. I had some somewhat nitpickey comments about the code style but I can change the code myself after merging this.
|
|
||
| def _handle_private_runners(self, runners): | ||
| sum_public = sum("robot:private" not in runner.tags for runner in runners) | ||
| sum_private = sum("robot:private" in runner.tags for runner in runners) |
There was a problem hiding this comment.
It's a bit questionable to use sum() with Boolean values but I guess it's ok here. The latter line could be simplified to:
sum_private = len(runners) - sum_public| sum_public = sum("robot:private" not in runner.tags for runner in runners) | ||
| sum_private = sum("robot:private" in runner.tags for runner in runners) | ||
|
|
||
| if sum_public == len(runners) or sum_private == len(runners) or sum_public > 1: |
There was a problem hiding this comment.
The first condition doesn't seem to be necessary. We only get to this function if there were multiple matches, so just having sum_public > 1 ought to be enough to cover also the sum_public == len(runners) case.
We generally haven't used empty lines between functions. If there's a need to use them for grouping code, we have typically created helper functions instead. That could be considered hare as well or possibly the empty lines could just be removed.
| public_runner = runner | ||
| private_runners = runners.copy() | ||
| private_runners.remove(public_runner) | ||
| break |
There was a problem hiding this comment.
Probably we could initially filter runners so that we have list of public and private runners instead of sum_xxx containing just their counts. Then this loop wouldn't needed at all.
| if runner != private_runners[-1]: | ||
| private_runners_str += f"'{runner.longname}' / " | ||
| else: | ||
| private_runners_str += f"'{runner.longname}'" |
There was a problem hiding this comment.
This looks a bit complicated way to concatenate names with / . Just using something like
private_runner_str = ' / '.join(r.longname for r in private_runners)ought to handler it as a one-liner. I'm also not certain is using / as a separator between private keywords here that good in general. Just listing all runners like 'First', 'Second' or 'Third would be simpler to implement and would look, in my opinion, clearer. I can test that in practice myself.
|
One thing I'm slightly concerned with this change is performance. Checking for private tags with all user keywords (i.e. |
Resolves #430.
robot:private.robot:privateare removed from libdoc's html output