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

typing annotation for gens method in rings and groups (pyx files) #39476

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

fchapoton
Copy link
Contributor

just adding annotation to remember what has been checked

📝 Checklist

  • The title is concise and informative.
  • The description explains in detail what this PR is about.

Copy link

github-actions bot commented Feb 7, 2025

Documentation preview for this PR (built with commit 450d6f6; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

Copy link
Contributor

@vincentmacri vincentmacri left a comment

Choose a reason for hiding this comment

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

A suggestion and a question.

@@ -362,7 +362,7 @@ class ParentLibGAP(SageObject):
for gap_subgroup in self._libgap.MaximalNormalSubgroups()]

@cached_method
def gens(self):
def gens(self) -> tuple:
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment applies to all your uses of the tuple/list annotation in this PR: for any of these, are you able to specify what type the tuple/list is composed of? Even if you can't get more precise than a fairly general class like Element, it would still be better than just a generic tuple. You can specify a tuple of for example three Elements by tuple[Element, Element, Element] or an unknown number of Elements by tuple[Element, ...]. Of course the most precise object you can use would be ideal. If there are really absolutely no guarantees on the type then I guess that's fine (but surely at least SageObject would work?).

"""
return [self.gen()]
return (self.gen(),)
Copy link
Contributor

Choose a reason for hiding this comment

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

While a tuple is probably a better choice here, is this not technically a breaking change? Since tuples have less capabilities than a list (since they are immutable)? Not sure what the deprecation rules would be here, or if they even apply.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the comments.

The aim is to make sure that all .gens method everywhere in sage all return either tuple or Family.

This may not be possible, but at least it is worth trying.

The annotation here is mostly to remember easily that this property has been checked. Refining this annotation would be better done in another occasion.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think what you wrote here addresses the other comment I made. I don't think it addresses my question of whether this is a breaking change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants