Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use base.ensure_key() in _build_key() to ensure consistency of enum keys between different Python versions #635

Merged
merged 1 commit into from
Jan 10, 2023

Conversation

padraic-shafer
Copy link
Contributor

New ensure_key() works with enum keys

BaseCache._build_key() uses ensure_key(key) to replace enum keys with the Enum's value (rather than the Enum object, as now happens in Python 3.11).

Are there changes in behavior for the user?

Enum keys (or string keys) can be used consistently across different Python versions.

Related issue number

Resolves #633.

Checklist

  • [X ] I think the code is well written
  • [X ] Unit tests for the changes exist
  • [X ] Documentation reflects the changes
  • [X ] Add a new news fragment into the CHANGES folder
    • name it <issue_id>.<type> (e.g. 588.bugfix)
    • if you don't have an issue_id change it to the pr id after creating the PR
    • ensure type is one of the following:
      • .feature: Signifying a new feature.
      • .bugfix: Signifying a bug fix.
      • .doc: Signifying a documentation improvement.
      • .removal: Signifying a deprecation or removal of public API.
      • .misc: A ticket has been closed, but it is not of interest to users.
    • Make sure to use full sentences with correct case and punctuation, for example: Fix issue with non-ascii contents in doctest text files.

@codecov
Copy link

codecov bot commented Jan 10, 2023

Codecov Report

Merging #635 (44cf6a0) into master (076ac89) will increase coverage by 0.01%.
The diff coverage is 100.00%.

❗ Current head 44cf6a0 differs from pull request most recent head 774c9ed. Consider uploading reports for the commit 774c9ed to get more accurate results

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #635      +/-   ##
==========================================
+ Coverage   99.66%   99.67%   +0.01%     
==========================================
  Files          36       36              
  Lines        3557     3713     +156     
==========================================
+ Hits         3545     3701     +156     
  Misses         12       12              
Flag Coverage Δ
unit 99.67% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
aiocache/backends/redis.py 99.16% <100.00%> (ø)
aiocache/base.py 99.27% <100.00%> (+0.03%) ⬆️
aiocache/decorators.py 100.00% <100.00%> (ø)
aiocache/lock.py 100.00% <100.00%> (ø)
tests/acceptance/test_decorators.py 100.00% <100.00%> (ø)
tests/acceptance/test_lock.py 100.00% <100.00%> (ø)
tests/performance/test_footprint.py 100.00% <100.00%> (ø)
tests/ut/backends/test_memcached.py 100.00% <100.00%> (ø)
tests/ut/backends/test_redis.py 100.00% <100.00%> (ø)
tests/ut/test_base.py 100.00% <100.00%> (ø)
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2cc74f7...774c9ed. Read the comment docs.

@Dreamsorcerer
Copy link
Member

Ah, I think you branched off your other PR. Unfortunately, we always squash commit, so that's messed up the diff/conflicts.

If you can rename it to _ensure_key(), as I'd like to replace it in the next release, and clean up the merge, that'd be great. We can push a new release once this is merged.

@padraic-shafer
Copy link
Contributor Author

Ah, I think you branched off your other PR. Unfortunately, we always squash commit, so that's messed up the diff/conflicts.

If you can rename it to _ensure_key(), as I'd like to replace it in the next release, and clean up the merge, that'd be great. We can push a new release once this is merged.

No problem. Will do that now.

@padraic-shafer
Copy link
Contributor Author

If you can rename it to _ensure_key(), as I'd like to replace it in the next release, and clean up the merge, that'd be great. We can push a new release once this is merged.

Done.

Thank you for nudging these tests along and for all your help. It's been a pleasure working with you on these PRs.

@Dreamsorcerer Dreamsorcerer merged commit c4fc8ba into aio-libs:master Jan 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ensure that underlying value of enum key is used by BaseCache._build_key() across Python versions
2 participants