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 — random.shuffle's random= argument got deprecated · Issue #1479 · pre-commit/pre-commit

random.shuffle's random= argument got deprecated #1479

New issue
Copy link
New issue
Copy link
Closed
#1480
Closed
random.shuffle's random= argument got deprecated#1479
#1480
Copy link
Labels
upstream-bug

Description

@isidentical
isidentical
opened on May 31, 2020
Issue body actions

Related issue: bpo-40465.

black..................................................................../home/isidentical/.venv/lib/python3.10/site-packages/pre_commit/languages/helpers.py:95: DeprecationWarning: The *random* parameter to shuffle() has been deprecated
since Python 3.9 and will be removed in a subsequent version.
  random.shuffle(seq, random=fixed_random.random)
Passed

Activity

  1. asottile commented on May 31, 2020

    @asottile
    asottile
    on May 31, 2020
    Member
    More actions

    well that's annoying.

  2. asottile
    added
    upstream-bug
    on May 31, 2020
  3. serhiy-storchaka commented on May 31, 2020

    @serhiy-storchaka
    serhiy-storchaka
    on May 31, 2020
    More actions

    Why not to use just

    fixed_random.shuffle(seq)

    ?

  4. asottile commented on May 31, 2020

    @asottile
    asottile
    on May 31, 2020
    Member
    More actions

    is that documented? I don't see it on https://docs.python.org/3/library/random.html

  5. serhiy-storchaka commented on May 31, 2020

    @serhiy-storchaka
    serhiy-storchaka
    on May 31, 2020
    More actions

    https://docs.python.org/3.9/library/random.html#random.shuffle

  6. asottile commented on May 31, 2020

    @asottile
    asottile
    on May 31, 2020
    Member
    More actions

    yeah that's what the current code is using?

  7. isidentical commented on May 31, 2020

    @isidentical
    isidentical
    on May 31, 2020
    Author
    More actions

    yeah that's what the current code is using?

    I think what @serhiy-storchaka is suggesting that, since you set a custom seed you can use directly fixed_random's shuffle method.

    def _shuffled(seq: Sequence[str]) -> List[str]:
        """Deterministically shuffle"""
        fixed_random = random.Random()
        fixed_random.seed(FIXED_RANDOM_SEED, version=1)
    
        seq = list(seq)
        fixed_random.shuffle(seq)
        return seq
  8. asottile commented on May 31, 2020

    @asottile
    asottile
    on May 31, 2020
    Member
    More actions

    I get that, but where in the documentation does it say that Random has a shuffle method -- the link above is to the module's function

  9. serhiy-storchaka commented on May 31, 2020

    @serhiy-storchaka
    serhiy-storchaka
    on May 31, 2020
    More actions

    The functions supplied by this module are actually bound methods of a hidden instance of the random.Random class. You can instantiate your own instances of Random to get generators that don’t share state.

  10. asottile commented on May 31, 2020

    @asottile
    asottile
    on May 31, 2020
    Member
    More actions

    🤦 and here I was expecting it to be documented under https://docs.python.org/3/library/random.html#random.Random

  11. asottile
    closed this as completedin #1480on May 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    upstream-bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — 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.