GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Shuffle arguments before running hooks by chriskuehl · Pull Request #874 · pre-commit/pre-commit

Conversation

@chriskuehl

@chriskuehl chriskuehl commented Nov 20, 2018

Copy link
Copy Markdown
Member

Fixes #861

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@chriskuehl
chriskuehl requested a review from asottile November 20, 2018 01:39
chriskuehl
chriskuehl commented Nov 20, 2018
View reviewed changes
Comment thread pre_commit/languages/helpers.py
fixed_random.seed(FIXED_RANDOM_SEED, version=1)

seq = list(seq)
random.shuffle(seq, random=fixed_random.random)

@chriskuehl chriskuehl Nov 20, 2018

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have to do kind of a weird dance to get these to shuffle identically between py2 and py3 -- fixed_random.shuffle won't work because in py3 random.shuffle picks a different algorithm than what's used in py2 if you don't specify random as a kwarg; random.sample which would probably be preferred to avoid turning it into a list and mutating it has a similar problem.

We probably don't really need it to be identical between py2 and py3, but it means we don't need to go fix a bunch of tests. Idk, worth it?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread tests/commands/install_uninstall_test.py Outdated
assert 'Failing hook' in output
assert 'Failed' in output
assert 'foo zzz' in output # both filenames should be printed
assert 'zzz foo' in output # both filenames should be printed

@chriskuehl chriskuehl Nov 20, 2018

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol i messed with the fixed random seed until only one test failed rather than a bunch

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@asottile asottile Nov 20, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol nice

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@chriskuehl chriskuehl Nov 20, 2018

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

derp, apparently this is actually passing as-is (i needed to pip install into my venv again)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
asottile
asottile approved these changes Nov 20, 2018
View reviewed changes
@chriskuehl
Shuffle arguments before running hooks
45e3dab
@chriskuehl
chriskuehl force-pushed the shuffle-args branch from f27e19b to 45e3dab Compare November 20, 2018 01:53
@asottile
asottile merged commit 51659ee into pre-commit:master Nov 20, 2018
@Dunedan Dunedan mentioned this pull request Nov 20, 2018
Concurrent execution results in uneven work per thread #861
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@asottile asottile asottile approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@chriskuehl @asottile
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.