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

any is a builtin, Any is a type -- use str over int #141

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

Conversation

esc
Copy link
Member

@esc esc commented Aug 2, 2024

As title

@esc esc changed the title any is a builtin, Any is a type any is a builtin, Any is a type -- use str over int Aug 2, 2024
arguments: list[any] = [],
unreachable: set[str] = set(),
empty: set[str] = set(),
arguments: list[Any] = [],
Copy link
Contributor

Choose a reason for hiding this comment

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

This might be unrelated but I am not sure it's good idea to have a list as a default argument? (Since it is mutable, it's generally not recommended to do that? )

Copy link
Member Author

Choose a reason for hiding this comment

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

In principle, yes. In this case the compare method treats these mutable structures as immutable, and so it's ok to define them as empty here. They are either empty or contain something, but will never be modified. It's a bit shorter than handing in None and then checking at the start of the function if the argument is None and the instantiating an empty container as a result.

@esc esc closed this Aug 5, 2024
@esc esc deleted the fix/typing_in_test branch August 5, 2024 15:35
@esc esc restored the fix/typing_in_test branch August 5, 2024 15:36
@esc esc reopened this Aug 5, 2024
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