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 | from neovim import attach |
||
12 | from neovim.compat import IS_PYTHON3 |
||
13 | |||
14 | |||
15 | CONFIG_FILES = ( |
||
16 | '.pynvim.yaml', |
||
17 | '~/.pynvim.yaml', |
||
18 | '~/.config/pynvim/config.yaml' |
||
19 | ) |
||
20 | |||
21 | |||
22 | def load_config(config_file): |
||
23 | """Load config values from yaml.""" |
||
24 | |||
25 | if config_file: |
||
26 | with open(config_file) as f: |
||
27 | return yaml.load(f) |
||
28 | |||
29 | else: |
||
30 | for config_file in CONFIG_FILES: |
||
31 | try: |
||
32 | with open(os.path.expanduser(config_file)) as f: |
||
33 | return yaml.load(f) |
||
34 | |||
35 | except IOError: |
||
36 | pass |
||
37 | |||
38 | return {} |
||
39 | |||
40 | |||
41 | # http://code.activestate.com/recipes/278731-creating-a-daemon-the-python-way/ |
||
42 | def detach_proc(workdir='.', umask=0): |
||
43 | """Detach a process from the controlling terminal and run it in the |
||
44 | background as a daemon. |
||
45 | """ |
||
46 | |||
47 | # Default maximum for the number of available file descriptors. |
||
48 | MAXFD = 1024 |
||
49 | |||
50 | # The standard I/O file descriptors are redirected to /dev/null by default. |
||
51 | if (hasattr(os, "devnull")): |
||
52 | REDIRECT_TO = os.devnull |
||
53 | else: |
||
54 | REDIRECT_TO = "/dev/null" |
||
55 | |||
56 | pid = os.fork() |
||
57 | if (pid == 0): |
||
58 | os.setsid() |
||
59 | |||
60 | pid = os.fork() |
||
61 | if (pid == 0): |
||
62 | os.chdir(workdir) |
||
63 | os.umask(umask) |
||
64 | else: |
||
65 | os._exit(0) |
||
66 | else: |
||
157 |
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.