Conditions | 9 |
Total Lines | 55 |
Lines | 0 |
Ratio | 0 % |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | """CLI for accessing the gtk/tickit UIs implemented by this package.""" |
||
11 | @click.command(context_settings=dict(allow_extra_args=True)) |
||
12 | @click.option('--prog') |
||
13 | @click.option('--notify', '-n', default=False, is_flag=True) |
||
14 | @click.option('--listen', '-l') |
||
15 | @click.option('--connect', '-c') |
||
16 | @click.option('--profile', |
||
17 | default='disable', |
||
18 | type=click.Choice(['ncalls', 'tottime', 'percall', 'cumtime', |
||
19 | 'name', 'disable'])) |
||
20 | @click.pass_context |
||
21 | def main(ctx, prog, notify, listen, connect, profile): |
||
22 | """Entry point.""" |
||
23 | address = connect or listen |
||
24 | |||
25 | if address: |
||
26 | import re |
||
27 | p = re.compile(r'^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(?:\:\d{1,5})?$') |
||
28 | |||
29 | if p.match(address): |
||
30 | args = ('tcp',) |
||
31 | kwargs = {'address': address} |
||
32 | else: |
||
33 | args = ('socket',) |
||
34 | kwargs = {'path': address} |
||
35 | |||
36 | if connect: |
||
37 | # connect to existing instance listening on address |
||
38 | nvim = attach(*args, **kwargs) |
||
39 | elif listen: |
||
40 | # spawn detached instance listening on address and connect to it |
||
41 | import os |
||
42 | import time |
||
43 | from subprocess import Popen |
||
44 | os.environ['NVIM_LISTEN_ADDRESS'] = address |
||
45 | nvim_argv = shlex.split(prog or 'nvim --headless') + ctx.args |
||
46 | # spawn the nvim with stdio redirected to /dev/null. |
||
47 | dnull = open(os.devnull) |
||
48 | p = Popen(nvim_argv, stdin=dnull, stdout=dnull, stderr=dnull) |
||
49 | dnull.close() |
||
50 | while p.poll() or p.returncode is None: |
||
51 | try: |
||
52 | nvim = attach(*args, **kwargs) |
||
53 | break |
||
54 | except IOError: |
||
55 | # socket not ready yet |
||
56 | time.sleep(0.050) |
||
57 | else: |
||
58 | # spawn embedded instance |
||
59 | nvim_argv = shlex.split(prog or 'nvim --embed') + ctx.args |
||
60 | nvim = attach('child', argv=nvim_argv) |
||
61 | |||
62 | from .gtk_ui import GtkUI |
||
63 | ui = GtkUI() |
||
64 | bridge = UIBridge() |
||
65 | bridge.connect(nvim, ui, profile if profile != 'disable' else None, notify) |
||
66 | |||
70 |
This can be caused by one of the following:
1. Missing Dependencies
This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.
2. Missing __init__.py files
This error could also result from missing
__init__.py
files in your module folders. Make sure that you place one file in each sub-folder.