| Conditions | 9 |
| Total Lines | 56 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 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('--font', '-f', default=('Monospace', 13), nargs=2) |
||
| 17 | @click.option('--profile', |
||
| 18 | default='disable', |
||
| 19 | type=click.Choice(['ncalls', 'tottime', 'percall', 'cumtime', |
||
| 20 | 'name', 'disable'])) |
||
| 21 | @click.pass_context |
||
| 22 | def main(ctx, prog, notify, listen, connect, font, profile): |
||
| 23 | """Entry point.""" |
||
| 24 | address = connect or listen |
||
| 25 | |||
| 26 | if address: |
||
| 27 | import re |
||
| 28 | p = re.compile(r'^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(?:\:\d{1,5})?$') |
||
| 29 | |||
| 30 | if p.match(address): |
||
| 31 | args = ('tcp',) |
||
| 32 | kwargs = {'address': address} |
||
| 33 | else: |
||
| 34 | args = ('socket',) |
||
| 35 | kwargs = {'path': address} |
||
| 36 | |||
| 37 | if connect: |
||
| 38 | # connect to existing instance listening on address |
||
| 39 | nvim = attach(*args, **kwargs) |
||
| 40 | elif listen: |
||
| 41 | # spawn detached instance listening on address and connect to it |
||
| 42 | import os |
||
| 43 | import time |
||
| 44 | from subprocess import Popen |
||
| 45 | os.environ['NVIM_LISTEN_ADDRESS'] = address |
||
| 46 | nvim_argv = shlex.split(prog or 'nvim --headless') + ctx.args |
||
| 47 | # spawn the nvim with stdio redirected to /dev/null. |
||
| 48 | dnull = open(os.devnull) |
||
| 49 | p = Popen(nvim_argv, stdin=dnull, stdout=dnull, stderr=dnull) |
||
| 50 | dnull.close() |
||
| 51 | while p.poll() or p.returncode is None: |
||
| 52 | try: |
||
| 53 | nvim = attach(*args, **kwargs) |
||
| 54 | break |
||
| 55 | except IOError: |
||
| 56 | # socket not ready yet |
||
| 57 | time.sleep(0.050) |
||
| 58 | else: |
||
| 59 | # spawn embedded instance |
||
| 60 | nvim_argv = shlex.split(prog or 'nvim --embed') + ctx.args |
||
| 61 | nvim = attach('child', argv=nvim_argv) |
||
| 62 | |||
| 63 | from .gtk_ui import GtkUI |
||
| 64 | ui = GtkUI(font) |
||
| 65 | bridge = UIBridge() |
||
| 66 | bridge.connect(nvim, ui, profile if profile != 'disable' else None, notify) |
||
| 67 | |||
| 71 |
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__.pyfiles in your module folders. Make sure that you place one file in each sub-folder.