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

Initial type annotations #39

Merged
merged 9 commits into from
Oct 27, 2019
Merged

Initial type annotations #39

merged 9 commits into from
Oct 27, 2019

Conversation

liam-m
Copy link
Owner

@liam-m liam-m commented Oct 27, 2019

No description provided.

"""
The index of the prime
"""
if not self or self[-1] < prime:
super().extend(primes_up_to(prime, self)[len(self):])
return super().index(prime)
return super().index(prime, start, stop or len(self))
Copy link
Owner Author

Choose a reason for hiding this comment

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

It's strange that we have to do stop or len(self), but without it we get

primes.py:61: error: Argument 3 to "index" of "list" has incompatible type "Optional[int]"; expected "int"

"""
List subclass that supports slicing and membership checking, automatically
generating new primes when needed
"""

def __contains__(self, item):
def __contains__(self, item: Any) -> bool:
Copy link
Owner Author

Choose a reason for hiding this comment

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

Ideally all of these parameters would be int rather than Any

@liam-m liam-m merged commit f9f5040 into master Oct 27, 2019
@liam-m liam-m deleted the initial-typing branch October 27, 2019 14:19
@liam-m liam-m mentioned this pull request Oct 27, 2019
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.

1 participant