def generate_config(self, stream=None, skipsections=(), encoding=None): """write a configuration file according to the current configuration into the given stream or stdout """ options_by_section = {} sections = [] for provider in self.options_providers: for section, options in provider.options_by_section(): if section is None: section = provider.name if section in skipsections: continue options = [(n, d, v) for (n, d, v) in options if d.get('type') is not None and not d.get('deprecated')] if not options: continue if section not in sections: sections.append(section) alloptions = options_by_section.setdefault(section, []) alloptions += options stream = stream or sys.stdout encoding = utils._get_encoding(encoding, stream) printed = False for section in sections: if printed: print('\n', file=stream) utils.format_section(stream, section.upper(), sorted(options_by_section[section]), encoding) printed = True
def generate_config(self, stream: TextIO | None = None, skipsections: tuple[str, ...] = ()) -> None: """Write a configuration file according to the current configuration into the given stream or stdout. """ options_by_section: dict[str, list[tuple[str, OptionDict, Any]]] = {} sections = [] for provider in self.options_providers: for section, options in provider.options_by_section(): if section is None: section = provider.name if section in skipsections: continue options = [ (n, d, v) for (n, d, v) in options if d.get("type") is not None and not d.get("deprecated") ] if not options: continue if section not in sections: sections.append(section) all_options = options_by_section.setdefault(section, []) all_options += options stream = stream or sys.stdout printed = False for section in sections: if printed: print("\n", file=stream) utils.format_section(stream, section.upper(), sorted(options_by_section[section])) printed = True
def generate_config( self, stream: Optional[TextIO] = None, skipsections: Tuple[str, ...] = () ) -> None: """DEPRECATED: Write a configuration file according to the current configuration into the given stream or stdout """ warnings.warn( "generate_config has been deprecated. It will be removed in pylint 3.0.", DeprecationWarning, ) options_by_section: Dict[str, List[Tuple]] = {} sections = [] for provider in self.options_providers: with warnings.catch_warnings(): warnings.filterwarnings("ignore", category=DeprecationWarning) for section, options in provider.options_by_section(): if section is None: section = provider.name if section in skipsections: continue options = [ # type: ignore[misc] (n, d, v) for (n, d, v) in options if d.get("type") is not None and not d.get("deprecated") ] if not options: continue if section not in sections: sections.append(section) all_options = options_by_section.setdefault(section, []) all_options += options stream = stream or sys.stdout printed = False for section in sections: if printed: print("\n", file=stream) with warnings.catch_warnings(): warnings.filterwarnings("ignore", category=DeprecationWarning) utils.format_section( stream, section.upper(), sorted(options_by_section[section]) ) printed = True