Merge pull request #1480 from pre-commit/random_meth

use the shuffle method of Random instead
This commit is contained in:
Anthony Sottile
2020-05-31 12:59:41 -07:00
committed by GitHub
3 changed files with 5 additions and 5 deletions

View File

@@ -10,7 +10,7 @@ resources:
type: github
endpoint: github
name: asottile/azure-pipeline-templates
ref: refs/tags/v1.0.0
ref: refs/tags/v2.0.0
jobs:
- template: job--pre-commit.yml@asottile
@@ -40,7 +40,7 @@ jobs:
displayName: install swift
- template: job--python-tox.yml@asottile
parameters:
toxenvs: [pypy3, py36, py37, py38]
toxenvs: [pypy3, py36, py37, py38, py39]
os: linux
pre_test:
- task: UseRubyVersion@0

View File

@@ -18,7 +18,7 @@ from pre_commit.xargs import xargs
if TYPE_CHECKING:
from typing import NoReturn
FIXED_RANDOM_SEED = 1542676186
FIXED_RANDOM_SEED = 1542676187
def run_setup_cmd(prefix: Prefix, cmd: Tuple[str, ...]) -> None:
@@ -92,7 +92,7 @@ def _shuffled(seq: Sequence[str]) -> List[str]:
fixed_random.seed(FIXED_RANDOM_SEED, version=1)
seq = list(seq)
random.shuffle(seq, random=fixed_random.random)
fixed_random.shuffle(seq)
return seq

View File

@@ -78,5 +78,5 @@ def test_target_concurrency_cpu_count_not_implemented():
def test_shuffled_is_deterministic():
seq = [str(i) for i in range(10)]
expected = ['3', '7', '8', '2', '4', '6', '5', '1', '0', '9']
expected = ['4', '0', '5', '1', '8', '6', '2', '3', '7', '9']
assert helpers._shuffled(seq) == expected