Method: pylint.config.arguments_manager._ArgumentsManager.optik_option
Calls: 1, Exceptions: 0, Paths: 1Back
Path 1: 1 calls (1.0)
SampleChecker (1)
'test-opt' (1)
{'action': 'store_true', 'help': 'help message'} (1)
tuple (1)
1def optik_option(
2 self, provider: ConfigProvider, opt: str, optdict: OptionDict
3 ) -> tuple[list[str], OptionDict]: # pragma: no cover
4 """DEPRECATED: Get our personal option definition and return a suitable form for
5 use with optik/optparse.
6 """
7 warnings.warn(
8 "optik_option has been deprecated. Parsing of option dictionaries should be done "
9 "automatically by initializing an ArgumentsProvider.",
10 DeprecationWarning,
11 stacklevel=2,
12 )
13 optdict = copy.copy(optdict)
14 if "action" in optdict:
15 self._nocallback_options[provider] = opt
16 else:
17 optdict["action"] = "callback"
18 optdict["callback"] = self.cb_set_provider_option
19 # default is handled here and *must not* be given to optik if you
20 # want the whole machinery to work
21 if "default" in optdict:
22 if (
23 "help" in optdict
24 and optdict.get("default") is not None
25 and optdict["action"] not in ("store_true", "store_false")
26 ):
27 optdict["help"] += " [current: %default]" # type: ignore[operator]
28 del optdict["default"]
29 args = ["--" + str(opt)]
30 if "short" in optdict:
31 self._short_options[optdict["short"]] = opt # type: ignore[index]
32 args.append("-" + optdict["short"]) # type: ignore[operator]
33 del optdict["short"]
34 # cleanup option definition dict before giving it to optik
35 for key in list(optdict.keys()):
36 if key not in self._optik_option_attrs:
37 optdict.pop(key)
38 return args, optdict