@@ -316,6 +316,7 @@ def __init__(
316316
317317 # Attributes related to stats
318318 self .stats = LinterStats ()
319+ self .skipped_paths : set [str ] = set ()
319320
320321 # Attributes related to (command-line) options and their parsing
321322 self .options : Options = options + _make_linter_options (self )
@@ -614,31 +615,39 @@ def initialize(self) -> None:
614615 if not msg .may_be_emitted (self .config .py_version ):
615616 self ._msgs_state [msg .msgid ] = False
616617
617- def _discover_files (self , files_or_modules : Sequence [str ]) -> Iterator [str ]:
618+ def _discover_files (
619+ self , files_or_modules : Sequence [str ], all_files : bool = False
620+ ) -> Iterator [str ]:
618621 """Discover python modules and packages in sub-directory.
619622
623+ :param Sequence[str] files_or_modules: list of directories to explore
624+ :param str all_files: whether to return _all_ files, entering modules
625+ and not considering ignored paths
620626 Returns iterator of paths to discovered modules and packages.
621627 """
622628 for something in files_or_modules :
623- if os .path .isdir (something ) and not os .path .isfile (
624- os .path .join (something , "__init__.py" )
625- ):
629+ if os .path .isdir (something ):
630+ if not all_files and not os .path .isfile (
631+ os .path .join (something , "__init__.py" )
632+ ):
633+ continue
626634 skip_subtrees : list [str ] = []
627635 for root , _ , files in os .walk (something ):
628636 if any (root .startswith (s ) for s in skip_subtrees ):
629637 # Skip subtree of already discovered package.
630638 continue
631639
632- if _is_ignored_file (
640+ if not all_files and _is_ignored_file (
633641 root ,
634642 self .config .ignore ,
635643 self .config .ignore_patterns ,
636644 self .config .ignore_paths ,
637645 ):
646+ self .skipped_paths .add (root )
638647 skip_subtrees .append (root )
639648 continue
640649
641- if "__init__.py" in files :
650+ if not all_files and "__init__.py" in files :
642651 skip_subtrees .append (root )
643652 yield root
644653 else :
@@ -851,6 +860,7 @@ def _get_file_descr_from_stdin(self, filepath: str) -> Iterator[FileItem]:
851860 self .config .ignore_patterns ,
852861 self .config .ignore_paths ,
853862 ):
863+ self .skipped_paths .add (filepath )
854864 return
855865
856866 try :
@@ -873,7 +883,9 @@ def _iterate_file_descrs(
873883 """
874884 for descr in self ._expand_files (files_or_modules ).values ():
875885 name , filepath , is_arg = descr ["name" ], descr ["path" ], descr ["isarg" ]
876- if self .should_analyze_file (name , filepath , is_argument = is_arg ):
886+ if descr ["isignored" ]:
887+ self .skipped_paths .add (filepath )
888+ elif self .should_analyze_file (name , filepath , is_argument = is_arg ):
877889 yield FileItem (name , filepath , descr ["basename" ])
878890
879891 def _expand_files (
@@ -1100,6 +1112,7 @@ def generate_reports(self, verbose: bool = False) -> int | None:
11001112
11011113 if self .config .reports :
11021114 self .reporter .display_reports (sect )
1115+
11031116 score_value = self ._report_evaluation (verbose )
11041117 # save results if persistent run
11051118 if self .config .persistent :
@@ -1143,8 +1156,11 @@ def _report_evaluation(self, verbose: bool = False) -> int | None:
11431156
11441157 if verbose :
11451158 checked_files_count = self .stats .node_count ["module" ]
1146- unchecked_files_count = self .stats .undocumented ["module" ]
1147- msg += f"\n Checked { checked_files_count } files, skipped { unchecked_files_count } files"
1159+ skipped_files = list (
1160+ self ._discover_files (list (self .skipped_paths ), all_files = True )
1161+ )
1162+ skipped_files_count = len (skipped_files )
1163+ msg += f"\n Checked { checked_files_count } files, skipped { skipped_files_count } files"
11481164
11491165 if self .config .score :
11501166 sect = report_nodes .EvaluationSection (msg )
0 commit comments