petl-developers / petl

Python Extract Transform and Load Tables of Data
MIT License
1.24k stars 193 forks source link

Resolve DeprecationWarning: Seeding based on hashing #656

Closed bmos closed 6 months ago

bmos commented 6 months ago

When calling randomtable without providing a seed, the warning DeprecationWarning: Seeding based on hashing is deprecated since Python 3.9 and will be removed in a subsequent version. The only supported seed types are: None, int, float, str, bytes, and bytearray. is emitted.

This actually becomes a TypeError in 3.11 and 3.12.

closes #657

It also seems like we don't even need to provide a seed based on the documentation, but I stuck to the way it was implemented before (using a hashed version of the date). 2.7: https://docs.python.org/2.7/library/random.html#random.seed 3.12: https://docs.python.org/3.12/library/random.html#random.seed

I also noticed that the filename utils/random.py seems to be conflicting with python's random module. When debugging the doctests in that file, I had to rename it.

Changes

Checklist

Use this checklist to ensure the quality of pull requests that include new code and/or make changes to existing code.

github-advanced-security[bot] commented 6 months ago

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

coveralls commented 6 months ago

Pull Request Test Coverage Report for Build 8238402266

Details


Changes Missing Coverage Covered Lines Changed/Added Lines %
petl/util/random.py 14 16 87.5%
<!-- Total: 56 58 96.55% -->
Files with Coverage Reduction New Missed Lines %
petl/version.py 2 81.82%
<!-- Total: 2 -->
Totals Coverage Status
Change from base Build 5940841807: 0.03%
Covered Lines: 13352
Relevant Lines: 14661

💛 - Coveralls