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

[Other] Method chunk_size typing and usage mismatch. #1486

Closed
yoonthegoon opened this issue Jul 23, 2023 · 2 comments
Closed

[Other] Method chunk_size typing and usage mismatch. #1486

yoonthegoon opened this issue Jul 23, 2023 · 2 comments

Comments

@yoonthegoon
Copy link
Contributor

While addressing #1383, I came across this.

Typing on method chunk_list suggests parameter items is type Sized.

@staticmethod
def chunk_list(items: Sized, chunk_size):
    # Based off of: https://github.com/apache/incubator-sdap-ingester
    return [items[i:i + chunk_size] for i in range(0, len(items), chunk_size)]

However, Sized is not indexable.
It's used in __main__.py where items = unique_resolved_domains where unique_resolved_domains is sometimes a list and sometimes a set.

In the case of unique_resolved_domains being a set, the method should fail as 'set' object is not subscriptable.

I would imagine the appropriate type hinting for chunk_size's items parameter would be Sequence.
I also imagine it's best to be consistent with the typing of unique_resolved_domains and make each instance of its declaration a list or tuple.

I will make the changes as I see fit in resolving #1383 but want to document this conflict.

@L1ghtn1ng
Copy link
Collaborator

L1ghtn1ng commented Jul 23, 2023 via email

@yoonthegoon
Copy link
Contributor Author

I think I could also make the type of items a Collection so that it would still be applicable to both set and list.
I would just have to modify the method to perform the logic on list(items).

yoonthegoon added a commit to yoonthegoon/theHarvester that referenced this issue Jul 24, 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

No branches or pull requests

2 participants