|
4 | 4 | import logging
|
5 | 5 | import re
|
6 | 6 | import sys
|
7 |
| -from collections.abc import Iterable, Mapping, Sequence |
| 7 | +from collections.abc import Mapping, Sequence |
8 | 8 | from dataclasses import dataclass
|
9 | 9 | from datetime import datetime
|
10 | 10 | from pathlib import Path
|
@@ -218,16 +218,6 @@ def _get_required_list_of_objects(
|
218 | 218 | return result
|
219 | 219 |
|
220 | 220 |
|
221 |
| -def _exactly_one(iterable: Iterable[object]) -> bool: |
222 |
| - found = False |
223 |
| - for item in iterable: |
224 |
| - if item: |
225 |
| - if found: |
226 |
| - return False |
227 |
| - found = True |
228 |
| - return found |
229 |
| - |
230 |
| - |
231 | 221 | def _validate_path_url(path: str | None, url: str | None) -> None:
|
232 | 222 | if not path and not url:
|
233 | 223 | raise PylockValidationError("path or url must be provided")
|
@@ -522,14 +512,14 @@ def __init__(
|
522 | 512 | if not is_normalized_name(self.name):
|
523 | 513 | raise PylockValidationError(f"Package name {self.name!r} is not normalized")
|
524 | 514 | if self.sdist or self.wheels:
|
525 |
| - if any([self.vcs, self.directory, self.archive]): |
| 515 | + if self.vcs or self.directory or self.archive: |
526 | 516 | raise PylockValidationError(
|
527 | 517 | "None of vcs, directory, archive "
|
528 | 518 | "must be set if sdist or wheels are set"
|
529 | 519 | )
|
530 | 520 | else:
|
531 | 521 | # no sdist nor wheels
|
532 |
| - if not _exactly_one([self.vcs, self.directory, self.archive]): |
| 522 | + if not (bool(self.vcs) ^ bool(self.directory) ^ bool(self.archive)): |
533 | 523 | raise PylockValidationError(
|
534 | 524 | "Exactly one of vcs, directory, archive must be set "
|
535 | 525 | "if sdist and wheels are not set"
|
|
0 commit comments