8000 Merge branch 'release/0.8.1' · python-mode/python-mode@c6a872a · GitHub
[go: up one dir, main page]

Skip to content

Commit c6a872a

Browse files
committed
Merge branch 'release/0.8.1'
2 parents af70229 + 66b70dd commit c6a872a

16 files changed

+279
-91
lines changed

Changelog.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Changelog
22
=========
33

4-
## 2013-12-04 0.8.0
4+
## 2014-06-11 0.8.1
55
-------------------
66
* Pylama updated to version 3.3.2
77
* Get fold's expression symbol from &fillchars;

autoload/pymode/troubleshooting.vim

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,26 @@ fun! pymode#troubleshooting#test() "{{{
1818

1919
call append('0', ['Pymode diagnostic',
2020
\ '===================',
21-
\ 'VIM:' . v:version . ', OS: ' . os .', multi_byte:' . has('multi_byte') . ', pymode: ' . g:pymode_version . ', python: ' . g:pymode_python,
21+
\ 'VIM:' . v:version . ', OS: ' . os .', multi_byte:' . has('multi_byte') . ', pymode: ' . g:pymode_version . ', pymode-python: ' . g:pymode_python,
2222
\ ''])
2323

2424
if !exists('#filetypeplugin')
2525
call append('$', ['WARNING: ', 'Python-mode required :filetype plugin indent on', ''])
2626
endif
2727

28+
call append('$', ['+python: ' . has('python')])
29+
call append('$', ['+python3: ' . has('python3'), ''])
30+
2831
if g:pymode_python == 'disable'
32+
2933
if !has('python') && !has('python3')
3034

31-
call append('$', ['WARNING: ', 'Python-mode required vim compiled with +python or +python3.',
35+
call append('$', ['WARNING: Python-mode required vim compiled with +python or +python3.',
3236
\ '"lint, rope, run, doc, virtualenv" features disabled.', ''])
3337

3438
else
3539

36-
call append('$', ['WARNING: ', 'Python is disabled by `pymode_python` option.',
40+
call append('$', ['WARNING: Python is disabled by `pymode_python` option.',
3741
\ '"lint, rope, run, doc, virtualenv" features disabled.', ''])
3842

3943
endif

doc/pymode.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
(__) (__) (__) (_) (_)(_____)(_)\_) (_/\/\_)(_____)(____/(____) ~
77

88

9-
Version: 0.8.0
9+
Version: 0.8.1
1010

1111
==============================================================================
1212
CONTENTS *pymode-contents*

plugin/pymode.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
" vi: fdl=1
2-
let g:pymode_version = "0.8.0"
2+
let g:pymode_version = "0.8.1"
33

44
com! PymodeVersion echomsg "Current python-mode version: " . g:pymode_version
55
com! PymodeTroubleshooting call pymode#troubleshooting#test()

pymode/__init__.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@ class Options(object):
2929

3030
def get_documentation():
3131
""" Search documentation and append to current buffer. """
32-
try:
33-
from StringIO import StringIO
34-
except ImportError:
35-
from io import StringIO
32+
from ._compat import StringIO
3633

3734
sys.stdout, _ = StringIO(), sys.stdout
3835
help(vim.eval('a:word'))

pymode/_compat.py

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
""" Compatibility.
2+
3+
Some py2/py3 compatibility support based on a stripped down
4+
version of six so we don't have to depend on a specific version
5+
of it.
6+
7+
:copyright: (c) 2014 by Armin Ronacher.
8+
:license: BSD
9+
"""
10+
import sys
11+
12+
PY2 = sys.version_info[0] == 2
13+
_identity = lambda x: x
14+
15+
16+
if not PY2:
17+
text_type = str
18+
string_types = (str,)
19+
integer_types = (int, )
20+
21+
iterkeys = lambda d: iter(d.keys())
22+
itervalues = lambda d: iter(d.values())
23+
iteritems = lambda d: iter(d.items())
24+
25+
from io import StringIO
26+
from queue import Queue # noqa
27+
28+
def reraise(tp, value, tb=None):
29+
if value.__traceback__ is not tb:
30+
raise value.with_traceback(tb)
31+
raise value
32+
33+
implements_to_string = _identity
34+
35+
else:
36+
text_type = unicode
37+
string_types = (str, unicode)
38+
integer_types = (int, long)
39+
40+
iterkeys = lambda d: d.iterkeys()
41+
itervalues = lambda d: d.itervalues()
42+
iteritems = lambda d: d.iteritems()
43+
44+
from cStringIO import StringIO
45+
from Queue import Queue
46+
47+
exec('def reraise(tp, value, tb=None):\n raise tp, value, tb')
48+
49+
def implements_to_string(cls):
50+
cls.__unicode__ = cls.__str__
51+
cls.__str__ = lambda x: x.__unicode__().encode('utf-8')
52+
return cls
53+
54+
55+
def with_metaclass(meta, *bases):
56+
# This requires a bit of explanation: the basic idea is to make a
57+
# dummy metaclass for one level of class instantiation that replaces
58+
# itself with the actual metaclass. Because of internal type checks
59+
# we also need to make sure that we downgrade the custom metaclass
60+
# for one level to something closer to type (that's why __call__ and
61+
# __init__ comes back from type etc.).
62+
#
63+
# This has the advantage over six.with_metaclass in that it does not
64+
# introduce dummy classes into the final MRO.
65+
class metaclass(meta):
66+
__call__ = type.__call__
67+
__init__ = type.__init__
68+
def __new__(cls, name, this_bases, d):
69+
if this_bases is None:
70+
return type.__new__(cls, name, (), d)
71+
return meta(name, bases, d)
72+
return metaclass('temporary_class', None, {})
73+
74+
75+
# Certain versions of pypy have a bug where clearing the exception stack
76+
# breaks the __exit__ function in a very peculiar way. This is currently
77+
# true for pypy 2.2.1 for instance. The second level of exception blocks
78+
# is necessary because pypy seems to forget to check if an exception
79+
# happend until the next bytecode instruction?
80+
BROKEN_PYPY_CTXMGR_EXIT = False
81+
if hasattr(sys, 'pypy_version_info'):
82+
class _Mgr(object):
83+
def __enter__(self):
84+
return self
85+
def __exit__(self, *args):
86+
sys.exc_clear()
87+
try:
88+
try:
89+
with _Mgr():
90+
raise AssertionError()
91+
except:
92+
raise
93+
except TypeError:
94+
BROKEN_PYPY_CTXMGR_EXIT = True
95+
except AssertionError:
96+
pass
97+
98+
# pylama:skip=1

pymode/async.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
""" Python-mode async support. """
22

3-
try:
4-
from Queue import Queue
5-
except ImportError:
6-
from queue import Queue # noqa
3+
from ._compat import Queue
74

85

96
RESULTS = Queue()

pymode/environment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import time
88
import os.path
99

10-
from .utils import PY2
10+
from ._compat import PY2
1111

1212

1313
class VimPymodeEnviroment(object):

pymode/libs/pylama/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
"""
77

8-
__version__ = "3.3.2"
8+
__version__ = "5.0.1"
99
__project__ = "pylama"
1010
__author__ = "Kirill Klenov <horneds@gmail.com>"
1111
__license__ = "GNU LGPL"

pymode/libs/pylama/config.py

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
""" Parse arguments from command line and configuration files. """
22
import fnmatch
33
import sys
4-
from os import getcwd, path
4+
import os
55
from re import compile as re
66

77
import logging
@@ -21,8 +21,11 @@
2121
#: A default checkers
2222
DEFAULT_LINTERS = 'pep8', 'pyflakes', 'mccabe'
2323

24-
CURDIR = getcwd()
25-
DEFAULT_INI_PATH = path.join(CURDIR, 'pylama.ini')
24+
CURDIR = os.getcwd()
25+
CONFIG_FILES = [
26+
os.path.join(CURDIR, basename) for basename in
27+
('pylama.ini', 'setup.cfg', 'tox.ini', 'pytest.ini')
28+
]
2629

2730

2831
class _Default(object):
@@ -67,7 +70,7 @@ def parse_linters(linters):
6770
PARSER = ArgumentParser(description="Code audit tool for python.")
6871
PARSER.add_argument(
6972
"path", nargs='?', default=_Default(CURDIR),
70-
help="Path on file or directory.")
73+
help="Path on file or directory for code check.")
7174

7275
PARSER.add_argument(
7376
"--verbose", "-v", action='store_true', help="Verbose mode.")
@@ -77,11 +80,11 @@ def parse_linters(linters):
7780

7881
PARSER.add_argument(
7982
"--format", "-f", default=_Default('pep8'), choices=['pep8', 'pylint'],
80-
help="Error format.")
83+
help="Choose errors format (pep8, pylint).")
8184

8285
PARSER.add_argument(
8386
"--select", "-s", default=_Default(''), type=split_csp_str,
84-
help="Select errors and warnings. (comma-separated)")
87+
help="Select errors and warnings. (comma-separated list)")
8588

8689

8790
PARSER.add_argument(
@@ -100,7 +103,7 @@ def parse_linters(linters):
100103
type=lambda s: [re(fnmatch.translate(p)) for p in s.split(',') if p],
101104
help="Skip files by masks (comma-separated, Ex. */messages.py)")
102105

103-
PARSER.add_argument("--report", "-r", help="Filename for report.")
106+
PARSER.add_argument("--report", "-r", help="Send report to file [REPORT]")
104107
PARSER.add_argument(
105108
"--hook", action="store_true", help="Install Git (Mercurial) hook.")
106109

@@ -110,7 +113,7 @@ def parse_linters(linters):
110113
"Dont supported with pylint.")
111114

112115
PARSER.add_argument(
113-
"--options", "-o", default=_Default(DEFAULT_INI_PATH),
116+
"--options", "-o", default="",
114117
help="Select configuration file. By default is '<CURDIR>/pylama.ini'")
115118

116119
PARSER.add_argument(
@@ -151,17 +154,22 @@ def parse_options(args=None, config=True, **overrides): # noqa
151154
setattr(options, k, _Default(v))
152155

153156
# Parse file related options
154-
for k, s in cfg.sections.items():
155-
if k == cfg.default_section:
157+
for name, opts in cfg.sections.items():
158+
159+
if not name.startswith('pylama'):
160+
continue
161+
162+
if name == cfg.default_section:
156163
continue
157-
if k in LINTERS:
158-
options.linter_params[k] = dict(s)
164+
165+
name = name[7:]
166+
167+
if name in LINTERS:
168+
options.linter_params[name] = dict(opts)
159169
continue
160-
mask = re(fnmatch.translate(k))
161-
options.file_params[mask] = dict(s)
162-
options.file_params[mask]['lint'] = int(
163-
options.file_params[mask].get('lint', 1)
164-
)
170+
171+
mask = re(fnmatch.translate(name))
172+
options.file_params[mask] = dict(opts)
165173

166174
# Postprocess options
167175
opts = dict(options.__dict__.items())
@@ -187,15 +195,21 @@ def process_value(name, value):
187195
return value
188196

189197

190-
def get_config(ini_path=DEFAULT_INI_PATH):
198+
def get_config(ini_path=None):
191199
""" Load configuration from INI.
192200
193201
:return Namespace:
194202
195203
"""
196204
config = Namespace()
197-
config.default_section = 'main'
198-
config.read(ini_path)
205+
config.default_section = 'pylama'
206+
207+
if not ini_path:
208+
for path in CONFIG_FILES:
209+
if os.path.isfile(path) and os.access(path, os.R_OK):
210+
config.read(path)
211+
else:
212+
config.read(ini_path)
199213

200214
return config
201215

@@ -207,3 +221,5 @@ def setup_logger(options):
207221
LOGGER.removeHandler(STREAM)
208222
LOGGER.addHandler(logging.FileHandler(options.report, mode='w'))
209223
LOGGER.info('Try to read configuration from: ' + options.options)
224+
225+
# pylama:ignore=W0212

pymode/libs/pylama/errors.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
# multiple statements on one line
3333
[('pylint', 'C0321'), ('pep8', 'E702')],
3434

35+
# bad indentation
36+
[('pylint', 'W0311'), ('pep8', 'E111')],
37+
3538
)
3639

3740
DUPLICATES = dict((key, values) for values in DUPLICATES for key in values)
@@ -57,6 +60,10 @@ def __getattr__(self, name):
5760
def __getitem__(self, name):
5861
return self._info[name]
5962

63+
def get(self, name, default=None):
64+
""" Implement dictionary `get` method. """
65+
return self._info.get(name, default)
66+
6067
def __repr__(self):
6168
return "<Error: %s %s>" % (self.number, self.linter)
6269

0 commit comments

Comments
 (0)
0