-
-
Notifications
You must be signed in to change notification settings - Fork 655
further typing annotations for methods has_something #40196
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
further typing annotations for methods has_something #40196
Conversation
Documentation preview for this PR (built with commit 6680d1f; changes) is ready! 🎉 |
@vincentmacri @tobiasdiez could you please have a look ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, one suggestion that you can take if you want.
@@ -1273,7 +1273,7 @@ def tamagawa_number(self, P, proof=None): | |||
|
|||
return self.local_data(P, proof).tamagawa_number() | |||
|
|||
def tamagawa_numbers(self): | |||
def tamagawa_numbers(self) -> list: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be list[Integer]
but if you want to leave specifying list types for future work that's fine too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer not. One point is that imho we should discuss and decide before moving forward : whether or not to distinguish between python integer
and Sage Integer
or just use a new abstract t_Integer
class for typing. We should also talk about what kind of type we should use for polynomials.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the return/input type is clear, then you can use the specific Python int
or sage Integer
class. For the case where either can be returned, I would say something like
type Intlike = int | sage.Integer
should work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't Sage use its own Integer type everywhere (or at least it should)? I think the only place where we would return a python integer is in magic methods like __len__
or __hash__
.
This is a more complicated matter for function parameters where many Sage functions (but not all) accept python ints.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't Sage use its own Integer type everywhere (or at least it should)? I think the only place where we would return a python integer is in magic methods like len or hash.
It's a somewhat stupid test, but there are over 1000 instances of return 0
. But yeah, most methods should return sage integer.
as a sequel of #40123
📝 Checklist