File tree Expand file tree Collapse file tree 2 files changed +23
-11
lines changed Expand file tree Collapse file tree 2 files changed +23
-11
lines changed Original file line number Diff line number Diff line change @@ -110,16 +110,25 @@ pub(crate) fn check_noqa(
110110 && !exemption. includes ( Rule :: UnusedNOQA )
111111 && !per_file_ignores. contains ( Rule :: UnusedNOQA )
112112 {
113- let directives = noqa_directives
114- . lines ( )
115- . iter ( )
116- . map ( |line| ( & line. directive , & line. matches , false ) )
117- . chain (
118- file_noqa_directives
119- . lines ( )
120- . iter ( )
121- . map ( |line| ( & line. parsed_file_exemption , & line. matches , true ) ) ,
122- ) ;
113+ let directives: Vec < _ > = if settings. preview . is_enabled ( ) {
114+ noqa_directives
115+ . lines ( )
116+ . iter ( )
117+ . map ( |line| ( & line. directive , & line. matches , false ) )
118+ . chain (
119+ file_noqa_directives
120+ . lines ( )
121+ . iter ( )
122+ . map ( |line| ( & line. parsed_file_exemption , & line. matches , true ) ) ,
123+ )
124+ . collect ( )
125+ } else {
126+ noqa_directives
127+ . lines ( )
128+ . iter ( )
129+ . map ( |line| ( & line. directive , & line. matches , false ) )
130+ . collect ( )
131+ } ;
123132 for ( directive, matches, is_file_level) in directives {
124133 match directive {
125134 Directive :: All ( directive) => {
Original file line number Diff line number Diff line change @@ -318,7 +318,10 @@ mod tests {
318318 fn ruff_noqa_filedirective_unused ( ) -> Result < ( ) > {
319319 let diagnostics = test_path (
320320 Path :: new ( "ruff/RUF100_6.py" ) ,
321- & settings:: LinterSettings :: for_rules ( vec ! [ Rule :: UnusedNOQA ] ) ,
321+ & settings:: LinterSettings {
322+ preview : PreviewMode :: Enabled ,
323+ ..settings:: LinterSettings :: for_rules ( vec ! [ Rule :: UnusedNOQA ] )
324+ } ,
322325 ) ?;
323326 assert_messages ! ( diagnostics) ;
324327 Ok ( ( ) )
You can’t perform that action at this time.
0 commit comments