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

Enforce @attr uses to always provide a return type #1782

Merged
merged 2 commits into from
Sep 4, 2024

Conversation

lgoettgens
Copy link
Collaborator

We have a lot of places in our codebases where people use @attr without specifying a return type, even though in many of these cases they are very easy too deduce (see e.g. all of the dim and is_* cases in oscar-system/Oscar.jl#4059). I don't know if this is due to people not knowing about the possibility, forget it, or just don't care. But at least for me, it is usually the second one (see e.g. the Lie algebra changes in oscar-system/Oscar.jl#4059).

Thus I propose to deprecate (in the next breaking release) the use of 1-arg @attr (with only a method expression) in favor of explicitly requiring people to write @attr Any if they don't want to think of the return type. I think this would be a good measure for enforcing better inferrable code (by just making it harder to shadow inference by accident). And this is something that can be easily adapted by a search-and-replace when doing the AA compat bump downstream.

As always, the change in deprecations.jl does not deprecate anything right now, it just provides Any as the return type to the 2-arg version, and makes it easy to deprecate it in a future breaking version bump.

Copy link

codecov bot commented Aug 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.03%. Comparing base (75a8537) to head (018f622).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1782      +/-   ##
==========================================
- Coverage   88.03%   88.03%   -0.01%     
==========================================
  Files         117      117              
  Lines       30094    30088       -6     
==========================================
- Hits        26494    26488       -6     
  Misses       3600     3600              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

src/Deprecations.jl Outdated Show resolved Hide resolved
@lgoettgens lgoettgens enabled auto-merge (squash) September 4, 2024 10:06
@lgoettgens
Copy link
Collaborator Author

@fingolfin the Singular test failure is unrelated. Can you force-merge this?

@fingolfin fingolfin merged commit 025eabc into Nemocas:master Sep 4, 2024
26 of 30 checks passed
@lgoettgens lgoettgens deleted the lg/attr branch September 4, 2024 11:40
@thofma
Copy link
Member

thofma commented Sep 5, 2024

Sorry, I am too slow, but I think this is a good idea.

lgoettgens added a commit to lgoettgens/Hecke.jl that referenced this pull request Sep 19, 2024
lgoettgens added a commit to lgoettgens/Hecke.jl that referenced this pull request Sep 19, 2024
lgoettgens added a commit to lgoettgens/Hecke.jl that referenced this pull request Sep 19, 2024
lgoettgens added a commit to lgoettgens/Hecke.jl that referenced this pull request Sep 19, 2024
lgoettgens added a commit to lgoettgens/Hecke.jl that referenced this pull request Sep 19, 2024
thofma pushed a commit to thofma/Hecke.jl that referenced this pull request Sep 19, 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.

3 participants