Coverage for C:\Repos\ekr-pylint\pylint\config\help_formatter.py: 42%

19 statements  

« prev     ^ index     » next       coverage.py v6.4, created at 2022-05-24 10:21 -0500

1# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html 

2# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE 

3# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt 

4 

5from __future__ import annotations 

6 

7import argparse 

8 

9from pylint.config.callback_actions import _CallbackAction 

10from pylint.constants import DEFAULT_PYLINT_HOME, OLD_DEFAULT_PYLINT_HOME 

11 

12 

13class _HelpFormatter(argparse.RawDescriptionHelpFormatter): 

14 """Formatter for the help message emitted by argparse.""" 

15 

16 def _get_help_string(self, action: argparse.Action) -> str | None: 

17 """Copied from argparse.ArgumentDefaultsHelpFormatter.""" 

18 assert action.help 

19 help_string = action.help 

20 

21 # CallbackActions don't have a default 

22 if isinstance(action, _CallbackAction): 

23 return help_string 

24 

25 if "%(default)" not in help_string: 

26 if action.default is not argparse.SUPPRESS: 

27 defaulting_nargs = [argparse.OPTIONAL, argparse.ZERO_OR_MORE] 

28 if action.option_strings or action.nargs in defaulting_nargs: 

29 help_string += " (default: %(default)s)" 

30 return help_string 

31 

32 @staticmethod 

33 def get_long_description() -> str: 

34 return f""" 

35Environment variables: 

36 The following environment variables are used: 

37 * PYLINTHOME Path to the directory where persistent data for the run will 

38 be stored. If not found, it defaults to '{DEFAULT_PYLINT_HOME}' 

39 or '{OLD_DEFAULT_PYLINT_HOME}' (in the current working directory). 

40 * PYLINTRC Path to the configuration file. See the documentation for the method used 

41 to search for configuration file. 

42 

43Output: 

44 Using the default text output, the message format is : 

45 

46 MESSAGE_TYPE: LINE_NUM:[OBJECT:] MESSAGE 

47 

48 There are 5 kind of message types : 

49 * (I) info, for informational messages 

50 * (C) convention, for programming standard violation 

51 * (R) refactor, for bad code smell 

52 * (W) warning, for python specific problems 

53 * (E) error, for probable bugs in the code 

54 * (F) fatal, if an error occurred which prevented pylint from doing further processing. 

55 

56Output status code: 

57 Pylint should leave with following bitwise status codes: 

58 * 0 if everything went fine 

59 * 1 if a fatal message was issued 

60 * 2 if an error message was issued 

61 * 4 if a warning message was issued 

62 * 8 if a refactor message was issued 

63 * 16 if a convention message was issued 

64 * 32 on usage error 

65"""