Skip to content

Commit 6e981ed

Browse files
Narrow down type ignore
Refs: #3371 (comment) Co-authored-by: Kevin Deldycke <kevin@deldycke.com>
1 parent 5989375 commit 6e981ed

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

src/click/types.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -544,19 +544,21 @@ def convert(
544544
import operator
545545

546546
rv = super().convert(value, param, ctx)
547-
lt_min: bool = self.min is not None and (
547+
min = self.min
548+
max = self.max
549+
lt_min: bool = min is not None and (
548550
operator.le if self.min_open else operator.lt
549-
)(rv, self.min) # type: ignore[arg-type]
550-
gt_max: bool = self.max is not None and (
551+
)(rv, min) # type: ignore[arg-type]
552+
gt_max: bool = max is not None and (
551553
operator.ge if self.max_open else operator.gt
552-
)(rv, self.max) # type: ignore[arg-type]
554+
)(rv, max) # type: ignore[arg-type]
553555

554556
if self.clamp:
555-
if lt_min:
556-
return self._clamp(self.min, 1, self.min_open) # type: ignore
557+
if min is not None and lt_min:
558+
return self._clamp(min, 1, self.min_open) # type: ignore[arg-type]
557559

558-
if gt_max:
559-
return self._clamp(self.max, -1, self.max_open) # type: ignore
560+
if max is not None and gt_max:
561+
return self._clamp(max, -1, self.max_open) # type: ignore[arg-type]
560562

561563
if lt_min or gt_max:
562564
self.fail(

0 commit comments

Comments
 (0)