@@ -38,6 +38,17 @@ class OptionsData(NamedTuple):
3838PYLINT_USERGUIDE_PATH = PYLINT_BASE_PATH / "doc" / "user_guide"
3939"""Path to the messages documentation folder."""
4040
41+ DYNAMICALLY_DEFINED_OPTIONS : dict [str , dict [str , str ]] = {
42+ # Option name, key / values we want to modify
43+ # At least default need to be defined
44+ "py-version" : {"default" : "sys.version_info[:2]" },
45+ "spelling-dict" : {
46+ "choices" : "enchant.Broker().list_dicts()" ,
47+ "default" : "" ,
48+ "help" : "Spelling dictionary name. Available dictionaries depends on your local enchant installation" ,
49+ },
50+ }
51+
4152
4253def _register_all_checkers_and_extensions (linter : PyLinter ) -> None :
4354 """Registers all checkers and extensions found in the default folders."""
@@ -49,12 +60,20 @@ def _get_all_options(linter: PyLinter) -> OptionsDataDict:
4960 """Get all options registered to a linter and return the data."""
5061 all_options : OptionsDataDict = defaultdict (list )
5162 for checker in sorted (linter .get_checkers ()):
52- ch_name = checker .name
53- for option in checker .options :
54- all_options [ch_name ].append (
63+ checker_name = checker .name
64+ for option_name , option_info in checker .options :
65+ changes_to_do = DYNAMICALLY_DEFINED_OPTIONS .get (option_name , {})
66+ if changes_to_do :
67+ for key_to_change , new_value in changes_to_do .items ():
68+ print (
69+ f"Doc value for { option_name !r} ['{ key_to_change } '] changed to "
70+ f"{ new_value !r} (instead of { option_info [key_to_change ]!r} )"
71+ )
72+ option_info [key_to_change ] = new_value
73+ all_options [checker_name ].append (
5574 OptionsData (
56- option [ 0 ] ,
57- option [ 1 ] ,
75+ option_name ,
76+ option_info ,
5877 checker ,
5978 getmodule (checker ).__name__ .startswith ("pylint.extensions." ), # type: ignore[union-attr]
6079 )
@@ -90,7 +109,10 @@ def _create_checker_section(
90109 continue
91110
92111 # Get current value of option
93- value = getattr (linter .config , option .name .replace ("-" , "_" ))
112+ if option .name not in DYNAMICALLY_DEFINED_OPTIONS :
113+ value = getattr (linter .config , option .name .replace ("-" , "_" ))
114+ else :
115+ value = DYNAMICALLY_DEFINED_OPTIONS [option .name ]["default" ]
94116
95117 # Create a comment if the option has no value
96118 if value is None :
0 commit comments