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

WIP: check for unknown kwargs in Index.select #2663

Open
wants to merge 2 commits into
base: try-submanifest
Choose a base branch
from

Conversation

ctb
Copy link
Contributor

@ctb ctb commented Jun 28, 2023

NOTE: PR into #2602

This PR adds a check for unknown kwargs into (most) Index.select calls, addressing #2259.

This is part of my review of #2602, where I was worried about whether all Index objects supported filter_manifest :).

@codecov
Copy link

codecov bot commented Jun 28, 2023

Codecov Report

Merging #2663 (8f58a1f) into try-submanifest (a8616b0) will increase coverage by 0.19%.
The diff coverage is 100.00%.

@@                 Coverage Diff                 @@
##           try-submanifest    #2663      +/-   ##
===================================================
+ Coverage            92.64%   92.84%   +0.19%     
===================================================
  Files                  104      104              
  Lines                12403    12412       +9     
  Branches              2610     2616       +6     
===================================================
+ Hits                 11491    11524      +33     
+ Misses                 613      587      -26     
- Partials               299      301       +2     
Flag Coverage Δ
hypothesis-py ?
python 92.84% <100.00%> (+0.19%) ⬆️

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

Files Changed Coverage Δ
src/sourmash/sbt.py 85.37% <ø> (ø)
src/sourmash/index/__init__.py 96.76% <100.00%> (+0.05%) ⬆️

... and 4 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Comment on lines +52 to +58
def _check_for_unknown_select_params(kwargs):
legit_param_names = { 'ksize', 'moltype', 'scaled', 'num', 'abund',
'containment', 'picklist', 'filter_manifest' } # @CTB picklist
kk = set(kwargs.keys())
assert kk.issubset(legit_param_names), kk - legit_param_names


Copy link
Member

Choose a reason for hiding this comment

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

Might be relevant: in #2726 I defined a Selection TypedDict to be able to

  1. use type checking
  2. being able to more easily convert a selection to Rust (the _selection_as_rust function).

Then the method signature for select becomes
def select(self, **kwargs: Unpack[Selection]):

(This is slightly annoying because the select method needs to extract the values from kwargs...)

PEP-692 has more details

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.

2 participants