peterbe / hashin

Helping you write hashed entries for packages in your requirements.txt
https://www.peterbe.com/plog/hashin
MIT License
105 stars 27 forks source link

Keep a consistant order for hashes for get_package_hashes. #131

Closed pcorpet closed 2 years ago

pcorpet commented 2 years ago

Fixes #126

MarkusH commented 2 years ago

This change raises an error for me on Python 3.9 and 3.10:

$ python -m hashin -r requirements.txt django
Traceback (most recent call last):
  File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/markus/Coding/hashin/hashin.py", line 855, in <module>
    sys.exit(main())
  File "/home/markus/Coding/hashin/hashin.py", line 837, in main
    return run(
  File "/home/markus/Coding/hashin/hashin.py", line 135, in run
    return run_packages(specs, requirements_file, *args, **kwargs)
  File "/home/markus/Coding/hashin/hashin.py", line 249, in run_packages
    for i, release in enumerate(data["hashes"], key=lambda r: r["hash"]):
TypeError: 'key' is an invalid keyword argument for enumerate()
$ hashin -r requirements.txt django
Traceback (most recent call last):
  File "/home/markus/Coding/hashin/venv39/bin/hashin", line 33, in <module>
    sys.exit(load_entry_point('hashin', 'console_scripts', 'hashin')())
  File "/home/markus/Coding/hashin/hashin.py", line 837, in main
    return run(
  File "/home/markus/Coding/hashin/hashin.py", line 135, in run
    return run_packages(specs, requirements_file, *args, **kwargs)
  File "/home/markus/Coding/hashin/hashin.py", line 249, in run_packages
    for i, release in enumerate(data["hashes"], key=lambda r: r["hash"]):
TypeError: 'key' is an invalid keyword argument for enumerate()
pcorpet commented 2 years ago

Oops, I was sloppy, sorry about that.

MarkusH commented 2 years ago

Works for me. Thank you!

peterbe commented 2 years ago

@pcorpet Would you mind editing the matrix in .github/workflows/python.yml and the Python version lists in tox.ini as part of this PR?

peterbe commented 2 years ago

In fact, perhaps it would be best to move the other linting tasks that, currently, 3.8 does into 3.10 in the tox file.

pcorpet commented 2 years ago

@peterbe it was actually failing on all versions before my fixes. But I'm all for clean commits and PRs so I'll send you another PR.

pcorpet commented 2 years ago

I also realize I forgot to update the version history...

pcorpet commented 2 years ago

I've rebased so that CI runs on python 3.9 and 3.10: ready to merge.