Skip to content

Commit f17a8c4

Browse files
committed
Minor cleanup after adding positional-only arg support
1 parent d917680 commit f17a8c4

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/robot/running/arguments/argumentspec.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ def positional(self):
5555

5656
@property
5757
def minargs(self):
58-
required = [arg for arg in self.positional if arg not in self.defaults]
59-
return len(required)
58+
return len([arg for arg in self.positional if arg not in self.defaults])
6059

6160
@property
6261
def maxargs(self):

src/robot/running/arguments/argumentvalidator.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ def validate(self, positional, named, dryrun=False):
3636
self._validate_no_extra_named(named, self._argspec)
3737

3838
def _validate_no_multiple_values(self, positional, named, spec):
39-
for name in (spec.positional_only + spec.positional_or_named)[:len(positional)]:
40-
if name in spec.positional_or_named and name in named:
41-
raise DataError("%s '%s' got multiple values for argument "
42-
"'%s'." % (spec.type, spec.name, name))
39+
for name in spec.positional[:len(positional)]:
40+
if name in named and name not in spec.positional_only:
41+
raise DataError("%s '%s' got multiple values for argument '%s'."
42+
% (spec.type, spec.name, name))
4343

4444
def _validate_no_positional_only_as_named(self, named, spec):
4545
if not spec.var_named:
@@ -70,8 +70,8 @@ def _raise_wrong_count(self, count, spec):
7070
% (spec.type, spec.name, expected, count))
7171

7272
def _validate_no_mandatory_missing(self, positional, named, spec):
73-
for name in spec.positional[len(positional):spec.minargs]:
74-
if name not in named:
73+
for name in spec.positional[len(positional):]:
74+
if name not in spec.defaults and name not in named:
7575
raise DataError("%s '%s' missing value for argument '%s'."
7676
% (spec.type, spec.name, name))
7777

0 commit comments

Comments
 (0)