mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
use the shuffle method of Random instead
This commit is contained in:
parent
d71699d7cd
commit
e120828042
3 changed files with 5 additions and 5 deletions
|
|
@ -10,7 +10,7 @@ resources:
|
||||||
type: github
|
type: github
|
||||||
endpoint: github
|
endpoint: github
|
||||||
name: asottile/azure-pipeline-templates
|
name: asottile/azure-pipeline-templates
|
||||||
ref: refs/tags/v1.0.0
|
ref: refs/tags/v2.0.0
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
- template: job--pre-commit.yml@asottile
|
- template: job--pre-commit.yml@asottile
|
||||||
|
|
@ -40,7 +40,7 @@ jobs:
|
||||||
displayName: install swift
|
displayName: install swift
|
||||||
- template: job--python-tox.yml@asottile
|
- template: job--python-tox.yml@asottile
|
||||||
parameters:
|
parameters:
|
||||||
toxenvs: [pypy3, py36, py37, py38]
|
toxenvs: [pypy3, py36, py37, py38, py39]
|
||||||
os: linux
|
os: linux
|
||||||
pre_test:
|
pre_test:
|
||||||
- task: UseRubyVersion@0
|
- task: UseRubyVersion@0
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ from pre_commit.xargs import xargs
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing import NoReturn
|
from typing import NoReturn
|
||||||
|
|
||||||
FIXED_RANDOM_SEED = 1542676186
|
FIXED_RANDOM_SEED = 1542676187
|
||||||
|
|
||||||
|
|
||||||
def run_setup_cmd(prefix: Prefix, cmd: Tuple[str, ...]) -> None:
|
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)
|
fixed_random.seed(FIXED_RANDOM_SEED, version=1)
|
||||||
|
|
||||||
seq = list(seq)
|
seq = list(seq)
|
||||||
random.shuffle(seq, random=fixed_random.random)
|
fixed_random.shuffle(seq)
|
||||||
return seq
|
return seq
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -78,5 +78,5 @@ def test_target_concurrency_cpu_count_not_implemented():
|
||||||
|
|
||||||
def test_shuffled_is_deterministic():
|
def test_shuffled_is_deterministic():
|
||||||
seq = [str(i) for i in range(10)]
|
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
|
assert helpers._shuffled(seq) == expected
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue