We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
gitlab --help requires a config file
## Description of the problem, including code/CLI snippet

`gitlab --help` reads its config file even when displaying help

## Expected Behavior

Print out the help text.

## Actual Behavior

Exits with error if no configuration file is found.

## Specifications

  - python-gitlab version: 1.5.0


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `gitlab/cli.py`
Content:
```
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 #
4 # Copyright (C) 2013-2017 Gauvain Pocentek <gauvain@pocentek.net>
5 #
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU Lesser General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU Lesser General Public License for more details.
15 #
16 # You should have received a copy of the GNU Lesser General Public License
17 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 
19 from __future__ import print_function
20 import argparse
21 import functools
22 import importlib
23 import re
24 import sys
25 
26 import gitlab.config
27 
28 camel_re = re.compile('(.)([A-Z])')
29 
30 # custom_actions = {
31 #    cls: {
32 #        action: (mandatory_args, optional_args, in_obj),
33 #    },
34 # }
35 custom_actions = {}
36 
37 
38 def register_custom_action(cls_names, mandatory=tuple(), optional=tuple()):
39     def wrap(f):
40         @functools.wraps(f)
41         def wrapped_f(*args, **kwargs):
42             return f(*args, **kwargs)
43 
44         # in_obj defines whether the method belongs to the obj or the manager
45         in_obj = True
46         classes = cls_names
47         if type(cls_names) != tuple:
48             classes = (cls_names, )
49 
50         for cls_name in classes:
51             final_name = cls_name
52             if cls_name.endswith('Manager'):
53                 final_name = cls_name.replace('Manager', '')
54                 in_obj = False
55             if final_name not in custom_actions:
56                 custom_actions[final_name] = {}
57 
58             action = f.__name__.replace('_', '-')
59             custom_actions[final_name][action] = (mandatory, optional, in_obj)
60 
61         return wrapped_f
62     return wrap
63 
64 
65 def die(msg, e=None):
66     if e:
67         msg = "%s (%s)" % (msg, e)
68     sys.stderr.write(msg + "\n")
69     sys.exit(1)
70 
71 
72 def what_to_cls(what):
73     return "".join([s.capitalize() for s in what.split("-")])
74 
75 
76 def cls_to_what(cls):
77     return camel_re.sub(r'\1-\2', cls.__name__).lower()
78 
79 
80 def _get_base_parser(add_help=True):
81     parser = argparse.ArgumentParser(
82         add_help=add_help,
83         description="GitLab API Command Line Interface")
84     parser.add_argument("--version", help="Display the version.",
85                         action="store_true")
86     parser.add_argument("-v", "--verbose", "--fancy",
87                         help="Verbose mode (legacy format only)",
88                         action="store_true")
89     parser.add_argument("-d", "--debug",
90                         help="Debug mode (display HTTP requests)",
91                         action="store_true")
92     parser.add_argument("-c", "--config-file", action='append',
93                         help=("Configuration file to use. Can be used "
94                               "multiple times."))
95     parser.add_argument("-g", "--gitlab",
96                         help=("Which configuration section should "
97                               "be used. If not defined, the default selection "
98                               "will be used."),
99                         required=False)
100     parser.add_argument("-o", "--output",
101                         help=("Output format (v4 only): json|legacy|yaml"),
102                         required=False,
103                         choices=['json', 'legacy', 'yaml'],
104                         default="legacy")
105     parser.add_argument("-f", "--fields",
106                         help=("Fields to display in the output (comma "
107                               "separated). Not used with legacy output"),
108                         required=False)
109 
110     return parser
111 
112 
113 def _get_parser(cli_module):
114     parser = _get_base_parser()
115     return cli_module.extend_parser(parser)
116 
117 
118 def _parse_value(v):
119     if isinstance(v, str) and v.startswith('@'):
120         # If the user-provided value starts with @, we try to read the file
121         # path provided after @ as the real value. Exit on any error.
122         try:
123             with open(v[1:]) as fl:
124                 return fl.read()
125         except Exception as e:
126             sys.stderr.write("%s\n" % e)
127             sys.exit(1)
128 
129     return v
130 
131 
132 def main():
133     if "--version" in sys.argv:
134         print(gitlab.__version__)
135         exit(0)
136 
137     parser = _get_base_parser(add_help=False)
138     # This first parsing step is used to find the gitlab config to use, and
139     # load the propermodule (v3 or v4) accordingly. At that point we don't have
140     # any subparser setup
141     (options, args) = parser.parse_known_args(sys.argv)
142 
143     config = gitlab.config.GitlabConfigParser(options.gitlab,
144                                               options.config_file)
145     cli_module = importlib.import_module('gitlab.v%s.cli' % config.api_version)
146 
147     # Now we build the entire set of subcommands and do the complete parsing
148     parser = _get_parser(cli_module)
149     args = parser.parse_args(sys.argv[1:])
150 
151     config_files = args.config_file
152     gitlab_id = args.gitlab
153     verbose = args.verbose
154     output = args.output
155     fields = []
156     if args.fields:
157         fields = [x.strip() for x in args.fields.split(',')]
158     debug = args.debug
159     action = args.action
160     what = args.what
161 
162     args = args.__dict__
163     # Remove CLI behavior-related args
164     for item in ('gitlab', 'config_file', 'verbose', 'debug', 'what', 'action',
165                  'version', 'output'):
166         args.pop(item)
167     args = {k: _parse_value(v) for k, v in args.items() if v is not None}
168 
169     try:
170         gl = gitlab.Gitlab.from_config(gitlab_id, config_files)
171         if gl.private_token or gl.oauth_token:
172             gl.auth()
173     except Exception as e:
174         die(str(e))
175 
176     if debug:
177         gl.enable_debug()
178 
179     cli_module.run(gl, what, action, args, verbose, output, fields)
180 
181     sys.exit(0)
182
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/gitlab/cli.py b/gitlab/cli.py
--- a/gitlab/cli.py
+++ b/gitlab/cli.py
@@ -98,7 +98,7 @@
                               "will be used."),
                         required=False)
     parser.add_argument("-o", "--output",
-                        help=("Output format (v4 only): json|legacy|yaml"),
+                        help="Output format (v4 only): json|legacy|yaml",
                         required=False,
                         choices=['json', 'legacy', 'yaml'],
                         default="legacy")
@@ -135,6 +135,10 @@
         exit(0)
 
     parser = _get_base_parser(add_help=False)
+    if "--help" in sys.argv or "-h" in sys.argv:
+        parser.print_help()
+        exit(0)
+
     # This first parsing step is used to find the gitlab config to use, and
     # load the propermodule (v3 or v4) accordingly. At that point we don't have
     # any subparser setup

{"golden_diff": "diff --git a/gitlab/cli.py b/gitlab/cli.py\n--- a/gitlab/cli.py\n+++ b/gitlab/cli.py\n@@ -98,7 +98,7 @@\n                               \"will be used.\"),\n                         required=False)\n     parser.add_argument(\"-o\", \"--output\",\n-                        help=(\"Output format (v4 only): json|legacy|yaml\"),\n+                        help=\"Output format (v4 only): json|legacy|yaml\",\n                         required=False,\n                         choices=['json', 'legacy', 'yaml'],\n                         default=\"legacy\")\n@@ -135,6 +135,10 @@\n         exit(0)\n \n     parser = _get_base_parser(add_help=False)\n+    if \"--help\" in sys.argv or \"-h\" in sys.argv:\n+        parser.print_help()\n+        exit(0)\n+\n     # This first parsing step is used to find the gitlab config to use, and\n     # load the propermodule (v3 or v4) accordingly. At that point we don't have\n     # any subparser setup\n", "issue": "gitlab --help requires a config file\n## Description of the problem, including code/CLI snippet\r\n\r\n`gitlab --help` reads its config file even when displaying help\r\n\r\n## Expected Behavior\r\n\r\nPrint out the help text.\r\n\r\n## Actual Behavior\r\n\r\nExits with error if no configuration file is found.\r\n\r\n## Specifications\r\n\r\n  - python-gitlab version: 1.5.0\r\n\n", "before_files": [{"content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n#\n# Copyright (C) 2013-2017 Gauvain Pocentek <gauvain@pocentek.net>\n#\n# This program is free software: you can redistribute it and/or modify\n# it under the terms of the GNU Lesser General Public License as published by\n# the Free Software Foundation, either version 3 of the License, or\n# (at your option) any later version.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU Lesser General Public License for more details.\n#\n# You should have received a copy of the GNU Lesser General Public License\n# along with this program.  If not, see <http://www.gnu.org/licenses/>.\n\nfrom __future__ import print_function\nimport argparse\nimport functools\nimport importlib\nimport re\nimport sys\n\nimport gitlab.config\n\ncamel_re = re.compile('(.)([A-Z])')\n\n# custom_actions = {\n#    cls: {\n#        action: (mandatory_args, optional_args, in_obj),\n#    },\n# }\ncustom_actions = {}\n\n\ndef register_custom_action(cls_names, mandatory=tuple(), optional=tuple()):\n    def wrap(f):\n        @functools.wraps(f)\n        def wrapped_f(*args, **kwargs):\n            return f(*args, **kwargs)\n\n        # in_obj defines whether the method belongs to the obj or the manager\n        in_obj = True\n        classes = cls_names\n        if type(cls_names) != tuple:\n            classes = (cls_names, )\n\n        for cls_name in classes:\n            final_name = cls_name\n            if cls_name.endswith('Manager'):\n                final_name = cls_name.replace('Manager', '')\n                in_obj = False\n            if final_name not in custom_actions:\n                custom_actions[final_name] = {}\n\n            action = f.__name__.replace('_', '-')\n            custom_actions[final_name][action] = (mandatory, optional, in_obj)\n\n        return wrapped_f\n    return wrap\n\n\ndef die(msg, e=None):\n    if e:\n        msg = \"%s (%s)\" % (msg, e)\n    sys.stderr.write(msg + \"\\n\")\n    sys.exit(1)\n\n\ndef what_to_cls(what):\n    return \"\".join([s.capitalize() for s in what.split(\"-\")])\n\n\ndef cls_to_what(cls):\n    return camel_re.sub(r'\\1-\\2', cls.__name__).lower()\n\n\ndef _get_base_parser(add_help=True):\n    parser = argparse.ArgumentParser(\n        add_help=add_help,\n        description=\"GitLab API Command Line Interface\")\n    parser.add_argument(\"--version\", help=\"Display the version.\",\n                        action=\"store_true\")\n    parser.add_argument(\"-v\", \"--verbose\", \"--fancy\",\n                        help=\"Verbose mode (legacy format only)\",\n                        action=\"store_true\")\n    parser.add_argument(\"-d\", \"--debug\",\n                        help=\"Debug mode (display HTTP requests)\",\n                        action=\"store_true\")\n    parser.add_argument(\"-c\", \"--config-file\", action='append',\n                        help=(\"Configuration file to use. Can be used \"\n                              \"multiple times.\"))\n    parser.add_argument(\"-g\", \"--gitlab\",\n                        help=(\"Which configuration section should \"\n                              \"be used. If not defined, the default selection \"\n                              \"will be used.\"),\n                        required=False)\n    parser.add_argument(\"-o\", \"--output\",\n                        help=(\"Output format (v4 only): json|legacy|yaml\"),\n                        required=False,\n                        choices=['json', 'legacy', 'yaml'],\n                        default=\"legacy\")\n    parser.add_argument(\"-f\", \"--fields\",\n                        help=(\"Fields to display in the output (comma \"\n                              \"separated). Not used with legacy output\"),\n                        required=False)\n\n    return parser\n\n\ndef _get_parser(cli_module):\n    parser = _get_base_parser()\n    return cli_module.extend_parser(parser)\n\n\ndef _parse_value(v):\n    if isinstance(v, str) and v.startswith('@'):\n        # If the user-provided value starts with @, we try to read the file\n        # path provided after @ as the real value. Exit on any error.\n        try:\n            with open(v[1:]) as fl:\n                return fl.read()\n        except Exception as e:\n            sys.stderr.write(\"%s\\n\" % e)\n            sys.exit(1)\n\n    return v\n\n\ndef main():\n    if \"--version\" in sys.argv:\n        print(gitlab.__version__)\n        exit(0)\n\n    parser = _get_base_parser(add_help=False)\n    # This first parsing step is used to find the gitlab config to use, and\n    # load the propermodule (v3 or v4) accordingly. At that point we don't have\n    # any subparser setup\n    (options, args) = parser.parse_known_args(sys.argv)\n\n    config = gitlab.config.GitlabConfigParser(options.gitlab,\n                                              options.config_file)\n    cli_module = importlib.import_module('gitlab.v%s.cli' % config.api_version)\n\n    # Now we build the entire set of subcommands and do the complete parsing\n    parser = _get_parser(cli_module)\n    args = parser.parse_args(sys.argv[1:])\n\n    config_files = args.config_file\n    gitlab_id = args.gitlab\n    verbose = args.verbose\n    output = args.output\n    fields = []\n    if args.fields:\n        fields = [x.strip() for x in args.fields.split(',')]\n    debug = args.debug\n    action = args.action\n    what = args.what\n\n    args = args.__dict__\n    # Remove CLI behavior-related args\n    for item in ('gitlab', 'config_file', 'verbose', 'debug', 'what', 'action',\n                 'version', 'output'):\n        args.pop(item)\n    args = {k: _parse_value(v) for k, v in args.items() if v is not None}\n\n    try:\n        gl = gitlab.Gitlab.from_config(gitlab_id, config_files)\n        if gl.private_token or gl.oauth_token:\n            gl.auth()\n    except Exception as e:\n        die(str(e))\n\n    if debug:\n        gl.enable_debug()\n\n    cli_module.run(gl, what, action, args, verbose, output, fields)\n\n    sys.exit(0)\n", "path": "gitlab/cli.py"}], "after_files": [{"content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n#\n# Copyright (C) 2013-2017 Gauvain Pocentek <gauvain@pocentek.net>\n#\n# This program is free software: you can redistribute it and/or modify\n# it under the terms of the GNU Lesser General Public License as published by\n# the Free Software Foundation, either version 3 of the License, or\n# (at your option) any later version.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU Lesser General Public License for more details.\n#\n# You should have received a copy of the GNU Lesser General Public License\n# along with this program.  If not, see <http://www.gnu.org/licenses/>.\n\nfrom __future__ import print_function\nimport argparse\nimport functools\nimport importlib\nimport re\nimport sys\n\nimport gitlab.config\n\ncamel_re = re.compile('(.)([A-Z])')\n\n# custom_actions = {\n#    cls: {\n#        action: (mandatory_args, optional_args, in_obj),\n#    },\n# }\ncustom_actions = {}\n\n\ndef register_custom_action(cls_names, mandatory=tuple(), optional=tuple()):\n    def wrap(f):\n        @functools.wraps(f)\n        def wrapped_f(*args, **kwargs):\n            return f(*args, **kwargs)\n\n        # in_obj defines whether the method belongs to the obj or the manager\n        in_obj = True\n        classes = cls_names\n        if type(cls_names) != tuple:\n            classes = (cls_names, )\n\n        for cls_name in classes:\n            final_name = cls_name\n            if cls_name.endswith('Manager'):\n                final_name = cls_name.replace('Manager', '')\n                in_obj = False\n            if final_name not in custom_actions:\n                custom_actions[final_name] = {}\n\n            action = f.__name__.replace('_', '-')\n            custom_actions[final_name][action] = (mandatory, optional, in_obj)\n\n        return wrapped_f\n    return wrap\n\n\ndef die(msg, e=None):\n    if e:\n        msg = \"%s (%s)\" % (msg, e)\n    sys.stderr.write(msg + \"\\n\")\n    sys.exit(1)\n\n\ndef what_to_cls(what):\n    return \"\".join([s.capitalize() for s in what.split(\"-\")])\n\n\ndef cls_to_what(cls):\n    return camel_re.sub(r'\\1-\\2', cls.__name__).lower()\n\n\ndef _get_base_parser(add_help=True):\n    parser = argparse.ArgumentParser(\n        add_help=add_help,\n        description=\"GitLab API Command Line Interface\")\n    parser.add_argument(\"--version\", help=\"Display the version.\",\n                        action=\"store_true\")\n    parser.add_argument(\"-v\", \"--verbose\", \"--fancy\",\n                        help=\"Verbose mode (legacy format only)\",\n                        action=\"store_true\")\n    parser.add_argument(\"-d\", \"--debug\",\n                        help=\"Debug mode (display HTTP requests)\",\n                        action=\"store_true\")\n    parser.add_argument(\"-c\", \"--config-file\", action='append',\n                        help=(\"Configuration file to use. Can be used \"\n                              \"multiple times.\"))\n    parser.add_argument(\"-g\", \"--gitlab\",\n                        help=(\"Which configuration section should \"\n                              \"be used. If not defined, the default selection \"\n                              \"will be used.\"),\n                        required=False)\n    parser.add_argument(\"-o\", \"--output\",\n                        help=\"Output format (v4 only): json|legacy|yaml\",\n                        required=False,\n                        choices=['json', 'legacy', 'yaml'],\n                        default=\"legacy\")\n    parser.add_argument(\"-f\", \"--fields\",\n                        help=(\"Fields to display in the output (comma \"\n                              \"separated). Not used with legacy output\"),\n                        required=False)\n\n    return parser\n\n\ndef _get_parser(cli_module):\n    parser = _get_base_parser()\n    return cli_module.extend_parser(parser)\n\n\ndef _parse_value(v):\n    if isinstance(v, str) and v.startswith('@'):\n        # If the user-provided value starts with @, we try to read the file\n        # path provided after @ as the real value. Exit on any error.\n        try:\n            with open(v[1:]) as fl:\n                return fl.read()\n        except Exception as e:\n            sys.stderr.write(\"%s\\n\" % e)\n            sys.exit(1)\n\n    return v\n\n\ndef main():\n    if \"--version\" in sys.argv:\n        print(gitlab.__version__)\n        exit(0)\n\n    parser = _get_base_parser(add_help=False)\n    if \"--help\" in sys.argv or \"-h\" in sys.argv:\n        parser.print_help()\n        exit(0)\n\n    # This first parsing step is used to find the gitlab config to use, and\n    # load the propermodule (v3 or v4) accordingly. At that point we don't have\n    # any subparser setup\n    (options, args) = parser.parse_known_args(sys.argv)\n\n    config = gitlab.config.GitlabConfigParser(options.gitlab,\n                                              options.config_file)\n    cli_module = importlib.import_module('gitlab.v%s.cli' % config.api_version)\n\n    # Now we build the entire set of subcommands and do the complete parsing\n    parser = _get_parser(cli_module)\n    args = parser.parse_args(sys.argv[1:])\n\n    config_files = args.config_file\n    gitlab_id = args.gitlab\n    verbose = args.verbose\n    output = args.output\n    fields = []\n    if args.fields:\n        fields = [x.strip() for x in args.fields.split(',')]\n    debug = args.debug\n    action = args.action\n    what = args.what\n\n    args = args.__dict__\n    # Remove CLI behavior-related args\n    for item in ('gitlab', 'config_file', 'verbose', 'debug', 'what', 'action',\n                 'version', 'output'):\n        args.pop(item)\n    args = {k: _parse_value(v) for k, v in args.items() if v is not None}\n\n    try:\n        gl = gitlab.Gitlab.from_config(gitlab_id, config_files)\n        if gl.private_token or gl.oauth_token:\n            gl.auth()\n    except Exception as e:\n        die(str(e))\n\n    if debug:\n        gl.enable_debug()\n\n    cli_module.run(gl, what, action, args, verbose, output, fields)\n\n    sys.exit(0)\n", "path": "gitlab/cli.py"}]}