- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 4.2k
          bevy_color: Apply #![deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)]
          #17090
        
          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
          
     Merged
      
      
            alice-i-cecile
  merged 4 commits into
  bevyengine:main
from
LikeLakers2:lint/deny_allow_and_without_reason/bevy_color
  
      
      
   
  Jan 5, 2025 
      
    
  
     Merged
                    
  
    bevy_color: Apply #![deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)]
  
  #17090
                      Changes from 2 commits
      Commits
    
    
            Show all changes
          
          
            4 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      910437a
              
                Apply `#[deny(clippy::allow_attributes)]` and `#[deny(clippy::allow_a…
              
              
                LikeLakers2 13745b6
              
                Please the almighty `rustfmt`
              
              
                LikeLakers2 df74dee
              
                Update the deny to link to the tracking issue
              
              
                LikeLakers2 1ff4c5a
              
                Merge branch 'main' into lint/deny_allow_and_without_reason/bevy_color
              
              
                LikeLakers2 File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -216,7 +216,10 @@ impl ColorToComponents for Oklaba { | |
| } | ||
| } | ||
|  | ||
| #[allow(clippy::excessive_precision)] | ||
| #[expect( | ||
| clippy::excessive_precision, | ||
| reason = "The code with excessive precision was copied from another codebase." | ||
| )] | ||
| impl From<LinearRgba> for Oklaba { | ||
| fn from(value: LinearRgba) -> Self { | ||
| let LinearRgba { | ||
|  | @@ -239,7 +242,10 @@ impl From<LinearRgba> for Oklaba { | |
| } | ||
| } | ||
|  | ||
| #[allow(clippy::excessive_precision)] | ||
| #[expect( | ||
| clippy::excessive_precision, | ||
| reason = "The code with excessive precision was copied from another codebase." | ||
| )] | ||
|          | ||
| impl From<Oklaba> for LinearRgba { | ||
| fn from(value: Oklaba) -> Self { | ||
| let Oklaba { | ||
|  | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.
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.
(Forgot to copy this comment over.)
I'm not really happy with these two lint attributes (this one, and the one shown in the comment below), as there really isn't a reason for the floats to have excessive precision, beyond the code having been copied verbatim from another code-base.
That said, I feel truncating the floats is out-of-scope for this PR, hence me changing the lint attributes to be
expect(...).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'd say the rationale could be to be consistent with other implementations?
But I agree that truncating the floats is out of scope here, also maybe for documentation purposes (If someone were to use our code as a template and worked with a greater precision. Alternatively you're expressing the intent of multiplying with these precise values, even if it's not going to be achievable with f32's.)
Uh oh!
There was an error while loading. Please reload this page.
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.
Hmm. I'm not so sure about that rationale, personally. I don't really know how to explain why, but it just doesn't sit right with me.
I mean, I'm willing to change it to that -
reason = "Excessive precision is used here to be consistent with other implementations."- but I'd maybe like a second opinion before I do that.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 like the reason in your last message better!
Uh oh!
There was an error while loading. Please reload this page.
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.
The original source of these numbers is actually https://bottosson.github.io/posts/oklab/#converting-from-linear-srgb-to-oklab.
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.
So should I change the reason to this?
reason = "Excessive precision is used here to be consistent with other implementations."Or are we still discussing what it should be?
Uh oh!
There was an error while loading. Please reload this page.
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 just truncate. The extra digits don't have a meaning. (Or you could say that the numbers match the reference implementation)
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.
@eero-lehtinen I would truncate - but honestly, doing so feels like it'd be out-of-scope for this PR.
Uh oh!
There was an error while loading. Please reload this page.
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.
That reason you suggested or what I said is completely fine. Just ship it.
Uh oh!
There was an error while loading. Please reload this page.
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.
Truncated floats are visible at this PR: #17109
I'm not a fan of the truncated floats, as they reduce readability... I would personally just do as I have in this PR, and move the allow to an expect.
But I'll see what Alice/other maintainers say.