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

chore: ban no arguments in IsListOrTuple #106

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

FBruzzesi
Copy link
Contributor

@FBruzzesi FBruzzesi commented Sep 15, 2024

Description

Closes #96

@FBruzzesi FBruzzesi changed the title chore: ban not argument in IsListOrTuple chore: ban no arguments in IsListOrTuple Sep 15, 2024
Comment on lines +90 to +92
allowed_type: Union[
Tuple[Type[List[Any]]], Tuple[Type[Tuple[Any, ...]]], Tuple[Type[List[Any]], Type[Tuple[Any, ...]]]
] = (list, tuple)
Copy link
Contributor Author

@FBruzzesi FBruzzesi Sep 15, 2024

Choose a reason for hiding this comment

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

This is a hack to be able to perform: ' or '.join(t.__name__ for t in self.allowed_type) and provide an error message specialized for each class.

The only other place in which allowed_type is if not isinstance(other, self.allowed_type): which would still be ok with the change:

- if not isinstance(other, list):
+ if not isinstance(other, (list, )):

@FBruzzesi FBruzzesi marked this pull request as ready for review September 18, 2024 07:28
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.

Enforce clearer usage of IsList() etc. with no arguments
1 participant